Skip to content

Commit

Permalink
Update tests to avoid depset union.
Browse files Browse the repository at this point in the history
    Progress towards bazelbuild/bazel#5817

    RELNOTES: None.
    PiperOrigin-RevId: 245242309
  • Loading branch information
Luca Di Grazia committed Sep 4, 2022
1 parent 299c4e5 commit c49a114
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ public void aspectsPropagatingForDefaultAndImplicit() throws Exception {
return ((Label) o).getName();
}));

assertThat(names).containsAtLeast("xxx", "yyy");
assertThat(names).containsAllOf("xxx", "yyy");
// Third is the C++ toolchain; its name changes between Blaze and Bazel.
assertThat(names).hasSize(3);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2916,28 +2916,6 @@ public void testNoRuleOutputsParam() throws Exception {
+ "re-enabled by setting --incompatible_no_rule_outputs_param=false");
}

@Test
public void testExecutableNotInRunfiles() throws Exception {
setSkylarkSemanticsOptions("--incompatible_disallow_struct_provider_syntax=false");
scratch.file(
"test/skylark/test_rule.bzl",
"def _my_rule_impl(ctx):",
" exe = ctx.actions.declare_file('exe')",
" ctx.actions.run_shell(outputs=[exe], command='touch exe')",
" runfile = ctx.actions.declare_file('rrr')",
" ctx.actions.run_shell(outputs=[runfile], command='touch rrr')",
" return struct(executable = exe, default_runfiles = ctx.runfiles(files = [runfile]))",
"my_rule = rule(implementation = _my_rule_impl, executable = True)");
scratch.file(
"test/skylark/BUILD",
"load('//test/skylark:test_rule.bzl', 'my_rule')",
"my_rule(name = 'target')");

reporter.removeHandler(failFastHandler);
getConfiguredTarget("//test/skylark:target");
assertContainsEvent("exe not included in runfiles");
}

/**
* Skylark integration test that forces inlining.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,7 @@ public void testResolveTools() throws Exception {
Iterables.getOnlyElement(
ruleContext.getRuleContext().getAnalysisEnvironment().getRegisteredActions());
assertThat(ActionsTestUtil.baseArtifactNames(action.getInputs()))
.containsAtLeast(
.containsAllOf(
"mytool.sh",
"mytool",
"foo_Smytool" + OsUtils.executableExtension() + "-runfiles",
Expand Down Expand Up @@ -2883,7 +2883,7 @@ public void testFilesToRunInActionsRun() throws Exception {
getGeneratingAction(
Iterables.getOnlyElement(r.getProvider(FileProvider.class).getFilesToBuild()));
assertThat(ActionsTestUtil.baseArtifactNames(action.getRunfilesSupplier().getArtifacts()))
.containsAtLeast("tool", "tool.sh", "data");
.containsAllOf("tool", "tool.sh", "data");
}

@Test
Expand Down Expand Up @@ -2911,7 +2911,7 @@ public void testFilesToRunInActionsTools() throws Exception {
getGeneratingAction(
Iterables.getOnlyElement(r.getProvider(FileProvider.class).getFilesToBuild()));
assertThat(ActionsTestUtil.baseArtifactNames(action.getRunfilesSupplier().getArtifacts()))
.containsAtLeast("tool", "tool.sh", "data");
.containsAllOf("tool", "tool.sh", "data");
}

// Verifies that configuration_field can only be used on 'label' attributes.
Expand Down Expand Up @@ -3208,4 +3208,3 @@ public String getMessage() {
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -1487,8 +1487,8 @@ public void testClassObjectAccess() throws Exception {
}

@Test
public void testInSetDeprecated() throws Exception {
new SkylarkTest("--incompatible_depset_is_not_iterable=false")
public void testInSet() throws Exception {
new SkylarkTest()
.testStatement("'b' in depset(['a', 'b'])", Boolean.TRUE)
.testStatement("'c' in depset(['a', 'b'])", Boolean.FALSE)
.testStatement("1 in depset(['a', 'b'])", Boolean.FALSE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,9 @@ public void testItemsAndTransitive() throws Exception {
public void testTooManyPositionals() throws Exception {
new BothModesTest()
.testIfErrorContains(
"expected no more than 2 positional arguments, but got 3", "depset([], 'default', [])");
"expected no more than 2 positional arguments, but got 3, for call to function "
+ "depset(items = [], order = \"default\", direct = None, transitive = None)",
"depset([], 'default', [])");
}


Expand Down

0 comments on commit c49a114

Please sign in to comment.