Skip to content

Commit

Permalink
Make FakeCppCompileAction fail if its source file doesn't compile wit…
Browse files Browse the repository at this point in the history
…hout any extra defines.

PiperOrigin-RevId: 153039146
  • Loading branch information
lberki authored and buchgr committed Apr 13, 2017
1 parent 8e04230 commit ac08077
Showing 1 changed file with 8 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import com.google.devtools.build.lib.rules.cpp.CcToolchainFeatures.FeatureConfiguration;
import com.google.devtools.build.lib.util.Preconditions;
import com.google.devtools.build.lib.util.ShellEscaper;
import com.google.devtools.build.lib.util.io.FileOutErr;
import com.google.devtools.build.lib.vfs.FileSystemUtils;
import com.google.devtools.build.lib.vfs.Path;
import com.google.devtools.build.lib.vfs.PathFragment;
Expand Down Expand Up @@ -141,19 +140,10 @@ public void execute(ActionExecutionContext actionExecutionContext)
CppCompileActionContext context = executor.getContext(actionContext);
CppCompileActionContext.Reply reply = null;
try {
// We delegate stdout/stderr to nowhere, i.e. same as redirecting to /dev/null.
reply = context.execWithReply(
this, actionExecutionContext.withFileOutErr(new FileOutErr()));
reply = context.execWithReply(this, actionExecutionContext);
} catch (ExecException e) {
// We ignore failures here (other than capturing the Distributor reply).
// The compilation may well fail (that's the whole point of negative compilation tests).
// We execute it here just for the side effect of generating the ".d" file.
reply = context.getReplyFromException(e, this);
if (reply == null) {
// This can only happen if the ExecException does not come from remote execution.
throw e.toActionExecutionException("Fake C++ Compilation of rule '"
+ getOwner().getLabel() + "'", executor.getVerboseFailures(), this);
}
throw e.toActionExecutionException("C++ compilation of rule '" + getOwner().getLabel() + "'",
executor.getVerboseFailures(), this);
}
IncludeScanningContext scanningContext = executor.getContext(IncludeScanningContext.class);
Path execRoot = executor.getExecRoot();
Expand Down Expand Up @@ -249,9 +239,8 @@ public String apply(String input) {
+ "mkdir -p " + outputPrefix + "$(dirname " + outputFile.getExecPath() + ")"
+ " && " + argv + "\n");
} catch (IOException e) {
throw new ActionExecutionException("failed to create fake compile command for rule '" +
getOwner().getLabel() + ": " + e.getMessage(),
this, false);
throw new ActionExecutionException("failed to create fake compile command for rule '"
+ getOwner().getLabel() + ": " + e.getMessage(), this, false);
}
}

Expand All @@ -261,7 +250,9 @@ protected PathFragment getInternalOutputFile() {
}

@Override
public String getMnemonic() { return "FakeCppCompile"; }
public String getMnemonic() {
return "FakeCppCompile";
}

@Override
public ResourceSet estimateResourceConsumptionLocal() {
Expand Down

0 comments on commit ac08077

Please sign in to comment.