diff options
author | Damien Martin-Guillerez <dmarting@google.com> | 2016-03-04 15:53:40 +0000 |
---|---|---|
committer | Damien Martin-Guillerez <dmarting@google.com> | 2016-03-04 16:16:52 +0000 |
commit | 16c33c3a8cb0d55a6f0f24806add771f324952ce (patch) | |
tree | 8542d4c5f3baaad6d18aaec58b9b5e0cb9206685 /src/test | |
parent | 738f7f674271e0c366976a8f8a635784760d4e2b (diff) |
Correctly report stderr content for repository_ctx.execute
The shell.Command class throw an exception when exit code is non
null, resulting in unwanted case where calling a failing command
as just echoing "Exited with status 4".
--
MOS_MIGRATED_REVID=116361594
Diffstat (limited to 'src/test')
-rwxr-xr-x | src/test/shell/bazel/skylark_repository_test.sh | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/test/shell/bazel/skylark_repository_test.sh b/src/test/shell/bazel/skylark_repository_test.sh index 7c6cb7b4ee..8207c5ccc6 100755 --- a/src/test/shell/bazel/skylark_repository_test.sh +++ b/src/test/shell/bazel/skylark_repository_test.sh @@ -299,6 +299,26 @@ EOF expect_log "version" } +function test_skylark_repository_execute_stderr() { + setup_skylark_repository + + cat >test.bzl <<EOF +def _impl(ctx): + result = ctx.execute([str(ctx.which("bash")), "-c", "echo erf >&2; exit 1"]) + if result.return_code != 1: + fail("Incorrect return code from bash (should be 1): " + result.return_code) + if result.stdout != "": + fail("Non-empty output: %s (stderr was %s)" % (result.stdout, result.stderr)) + print(result.stderr) + # Symlink so a repository is created + ctx.symlink(ctx.path("$repo2"), ctx.path("")) +repo = repository_rule(implementation=_impl, local=True) +EOF + + bazel build @foo//:bar >& $TEST_log || fail "Failed to build" + expect_log "erf" +} + function test_skylark_repository_environ() { setup_skylark_repository |