Skip to content
This repository has been archived by the owner on Nov 10, 2023. It is now read-only.

Commit

Permalink
genrule() should fail if any command fails.
Browse files Browse the repository at this point in the history
Summary:
From #16.

If a genrule is a complex sequence of shell commands the rule
should fail if any of the commands fails and its exit status was
not examined.

Fixes #21

Test Plan: Sandcastle builds.
  • Loading branch information
spearce authored and bolinfest committed Sep 25, 2013
1 parent 2aef431 commit a9ae261
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/com/facebook/buck/shell/AbstractGenruleStep.java
Expand Up @@ -103,7 +103,7 @@ public String getShortName() {
protected ImmutableList<String> getShellCommandInternal(ExecutionContext context) {
// The priority sequence is
// "cmd.exe /c winCommand" (Windows Only)
// "/bin/bash -c shCommand" (Non-windows Only)
// "/bin/bash -e -c shCommand" (Non-windows Only)
// "(/bin/bash -c) or (cmd.exe /c) cmd" (All platforms)
String command;
if (context.getPlatform() == Platform.WINDOWS) {
Expand All @@ -129,7 +129,7 @@ protected ImmutableList<String> getShellCommandInternal(ExecutionContext context
getFullyQualifiedName());
}
command = replaceMatches(context.getProjectFilesystem(), commandInUse);
return ImmutableList.of("/bin/bash", "-c", command);
return ImmutableList.of("/bin/bash", "-e", "-c", command);
}
}

Expand Down
2 changes: 1 addition & 1 deletion test/com/facebook/buck/android/ApkGenruleTest.java
Expand Up @@ -223,7 +223,7 @@ public void testCreateAndRunApkGenrule() throws IOException, NoSuchBuildTargetEx
.put("OUT", expectedApkOutput).build(),
genruleCommand.getEnvironmentVariables(executionContext));
assertEquals(
ImmutableList.of("/bin/bash", "-c", "python signer.py $APK key.properties > $OUT"),
ImmutableList.of("/bin/bash", "-e", "-c", "python signer.py $APK key.properties > $OUT"),
genruleCommand.getShellCommand(executionContext));

EasyMock.verify(parser);
Expand Down
6 changes: 3 additions & 3 deletions test/com/facebook/buck/shell/GenruleTest.java
Expand Up @@ -233,7 +233,7 @@ public void testCreateAndRunGenrule() throws IOException, NoSuchBuildTargetExcep
.build(),
genruleCommand.getEnvironmentVariables(executionContext));
assertEquals(
ImmutableList.of("/bin/bash", "-c", "python convert_to_katana.py AndroidManifest.xml > $OUT"),
ImmutableList.of("/bin/bash", "-e", "-c", "python convert_to_katana.py AndroidManifest.xml > $OUT"),
genruleCommand.getShellCommand(executionContext));
}

Expand Down Expand Up @@ -511,7 +511,7 @@ public void testGetShellCommand() {
.build(new BuildRuleResolver());

ImmutableList<String> command = rule.createGenruleStep().getShellCommand(linuxExecutionContext);
assertEquals(ImmutableList.of("/bin/bash", "-c", bash), command);
assertEquals(ImmutableList.of("/bin/bash", "-e", "-c", bash), command);

command = rule.createGenruleStep().getShellCommand(windowsExecutionContext);
assertEquals(ImmutableList.of("cmd.exe", "/c", cmdExe), command);
Expand All @@ -523,7 +523,7 @@ public void testGetShellCommand() {
.setOut("out.txt")
.build(new BuildRuleResolver());
command = rule.createGenruleStep().getShellCommand(linuxExecutionContext);
assertEquals(ImmutableList.of("/bin/bash", "-c", cmd), command);
assertEquals(ImmutableList.of("/bin/bash", "-e", "-c", cmd), command);

command = rule.createGenruleStep().getShellCommand(windowsExecutionContext);
assertEquals(ImmutableList.of("cmd.exe", "/c", cmd), command);
Expand Down

0 comments on commit a9ae261

Please sign in to comment.