Skip to content

Commit

Permalink
Prep build output tests for sh_library as a Starlark rule
Browse files Browse the repository at this point in the history
When sh_library is implemented as a Starlark rule, the traceback includes the
location of the  sh_library implementation.  Because this would make the test
fragile, this CL adjusts tests in two different ways:

1) checking only the portion of the traceback for the pieces defined in the test.
2) implementing the test using filegroup instead of sh_library.

TESTED:
Ran these tests with and without a patch to exports.bzl that enables
the sh_library as a Starlark rule by default.
PiperOrigin-RevId: 453370399
Change-Id: Ic3ad637e170186abc4c27d2b8682d3dbaa738aff
  • Loading branch information
Googler authored and copybara-github committed Jun 7, 2022
1 parent 7de4fab commit 0529fdb
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ public void ruleStackRegressionTest() throws Exception {
write(
"package/inc.bzl",
"def g(name):",
" native.sh_library(name = name)",
" native.filegroup(name = name)",
"",
"def f(name):",
" g(name)");
Expand All @@ -650,7 +650,7 @@ public void ruleStackRegressionTest() throws Exception {
"# "
+ workspaceDir
+ "/package/BUILD:2:2\n"
+ "sh_library(\n"
+ "filegroup(\n"
+ " name = \"a\",\n"
+ " generator_name = \"a\",\n"
+ " generator_function = \"f\",\n"
Expand All @@ -666,12 +666,12 @@ public void ruleStackRegressionTest() throws Exception {
+ "/package/inc.bzl:5:6 in f\n"
+ "# "
+ workspaceDir
+ "/package/inc.bzl:2:22 in g\n"
+ "/package/inc.bzl:2:21 in g\n"
+ "\n"
+ "# "
+ workspaceDir
+ "/package/BUILD:3:2\n"
+ "sh_library(\n"
+ "filegroup(\n"
+ " name = \"b\",\n"
+ " generator_name = \"b\",\n"
+ " generator_function = \"f\",\n"
Expand All @@ -687,7 +687,7 @@ public void ruleStackRegressionTest() throws Exception {
+ "/package/inc.bzl:5:6 in f\n"
+ "# "
+ workspaceDir
+ "/package/inc.bzl:2:22 in g\n\n";
+ "/package/inc.bzl:2:21 in g\n\n";

String out = new String(result.getStdout(), UTF_8);
assertThat(out).isEqualTo(expectedOut);
Expand Down

0 comments on commit 0529fdb

Please sign in to comment.