Update tests in preparation for incompatible_new_actions_api flag flip
RELNOTES: None.
PiperOrigin-RevId: 249844142
diff --git a/src/test/java/com/google/devtools/build/lib/skylark/SkylarkActionProviderTest.java b/src/test/java/com/google/devtools/build/lib/skylark/SkylarkActionProviderTest.java
index c37c494..befdd40 100644
--- a/src/test/java/com/google/devtools/build/lib/skylark/SkylarkActionProviderTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skylark/SkylarkActionProviderTest.java
@@ -98,9 +98,9 @@
scratch.file(
"test/rule.bzl",
"def impl(ctx):",
- " output_file0 = ctx.new_file('myfile0')",
- " output_file1 = ctx.new_file('myfile1')",
- " executable = ctx.new_file('executable')",
+ " output_file0 = ctx.actions.declare_file('myfile0')",
+ " output_file1 = ctx.actions.declare_file('myfile1')",
+ " executable = ctx.actions.declare_file('executable')",
" ctx.actions.run(outputs=[output_file0], executable=executable,",
" mnemonic='MyAction0', env={'foo':'bar', 'pet':'puppy'})",
" ctx.actions.run_shell(outputs=[executable, output_file1],",
diff --git a/src/test/java/com/google/devtools/build/lib/skylark/SkylarkDefinedAspectsTest.java b/src/test/java/com/google/devtools/build/lib/skylark/SkylarkDefinedAspectsTest.java
index 1b8065d..20ee43c 100644
--- a/src/test/java/com/google/devtools/build/lib/skylark/SkylarkDefinedAspectsTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skylark/SkylarkDefinedAspectsTest.java
@@ -957,7 +957,7 @@
"test/aspect.bzl",
"def _impl(target, ctx):",
" f = ctx.actions.declare_file('f.txt')",
- " ctx.file_action(f, 'f')",
+ " ctx.actions.write(f, 'f')",
" return struct(output_groups = { 'duplicate' : depset([f]) })",
"",
"MyAspect = aspect(implementation=_impl)",
diff --git a/src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleContextTest.java b/src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleContextTest.java
index 566e25c..7e2428b 100644
--- a/src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleContextTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleContextTest.java
@@ -833,6 +833,7 @@
@Test
public void testDeriveArtifactLegacy() throws Exception {
+ setSkylarkSemanticsOptions("--incompatible_new_actions_api=false");
SkylarkRuleContext ruleContext = createRuleContext("//foo:foo");
Object result =
evalRuleContextCode(
@@ -845,7 +846,7 @@
@Test
public void testDeriveArtifact() throws Exception {
SkylarkRuleContext ruleContext = createRuleContext("//foo:foo");
- Object result = evalRuleContextCode(ruleContext, "ruleContext.new_file('a/b.txt')");
+ Object result = evalRuleContextCode(ruleContext, "ruleContext.actions.declare_file('a/b.txt')");
PathFragment fragment = ((Artifact) result).getRootRelativePath();
assertThat(fragment.getPathString()).isEqualTo("foo/a/b.txt");
}
@@ -889,6 +890,7 @@
@Test
public void testParamFileLegacy() throws Exception {
+ setSkylarkSemanticsOptions("--incompatible_new_actions_api=false");
SkylarkRuleContext ruleContext = createRuleContext("//foo:foo");
Object result =
evalRuleContextCode(
@@ -901,6 +903,7 @@
@Test
public void testParamFileSuffixLegacy() throws Exception {
+ setSkylarkSemanticsOptions("--incompatible_new_actions_api=false");
SkylarkRuleContext ruleContext = createRuleContext("//foo:foo");
Object result =
evalRuleContextCode(
@@ -2274,6 +2277,7 @@
@Test
public void testFrozenRuleContextHasInaccessibleAttributes() throws Exception {
+ setSkylarkSemanticsOptions("--incompatible_new_actions_api=false");
scratch.file("test/BUILD",
"load('//test:rules.bzl', 'main_rule', 'dep_rule')",
"dep_rule(name = 'dep')",
@@ -2316,6 +2320,7 @@
@Test
public void testFrozenRuleContextForAspectsHasInaccessibleAttributes() throws Exception {
+ setSkylarkSemanticsOptions("--incompatible_new_actions_api=false");
List<String> attributes = new ArrayList<>();
attributes.addAll(ctxAttributes);
attributes.addAll(ImmutableList.of(
diff --git a/src/test/java/com/google/devtools/build/lib/skylark/SkylarkStringRepresentationsTest.java b/src/test/java/com/google/devtools/build/lib/skylark/SkylarkStringRepresentationsTest.java
index 52590c1..ddcccbb 100644
--- a/src/test/java/com/google/devtools/build/lib/skylark/SkylarkStringRepresentationsTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skylark/SkylarkStringRepresentationsTest.java
@@ -173,7 +173,7 @@
"dep = rule(implementation = _impl)",
"",
"def _genfile_impl(ctx):",
- " ctx.file_action(output = ctx.outputs.my_output, content = 'foo')",
+ " ctx.actions.write(output = ctx.outputs.my_output, content = 'foo')",
"genfile = rule(",
" implementation = _genfile_impl,",
" outputs = {'my_output': '%{name}.txt'},",
diff --git a/src/test/shell/integration/bazel_worker_test.sh b/src/test/shell/integration/bazel_worker_test.sh
index 24a5ade..0714bf1 100755
--- a/src/test/shell/integration/bazel_worker_test.sh
+++ b/src/test/shell/integration/bazel_worker_test.sh
@@ -112,8 +112,7 @@
# This is used to test the code that handles multiple flagfiles and the --flagfile= style.
idx = 1
for arg in ["--output_file=" + output.path] + ctx.attr.args:
- argfile = ctx.new_file(ctx.bin_dir, "%s_worker_input_%s" % (ctx.label.name, idx))
- ctx.file_action(output=argfile, content=arg)
+ argfile = ctx.actions.declare_file("%s_worker_input_%s" % (ctx.label.name, idx))
ctx.actions.write(output=argfile, content=arg)
argfile_inputs.append(argfile)
flagfile_prefix = "@" if (idx % 2 == 0) else "--flagfile="
@@ -121,7 +120,7 @@
idx += 1
else:
# Generate the "@"-file containing the command-line args for the unit of work.
- argfile = ctx.new_file(ctx.bin_dir, "%s_worker_input" % ctx.label.name)
+ argfile = ctx.actions.declare_file("%s_worker_input" % ctx.label.name)
argfile_contents = "\n".join(["--output_file=" + output.path] + ctx.attr.args)
ctx.actions.write(output=argfile, content=argfile_contents)
argfile_inputs.append(argfile)
diff --git a/src/test/shell/integration/outputs_test.sh b/src/test/shell/integration/outputs_test.sh
index ad6b67c..2863318 100755
--- a/src/test/shell/integration/outputs_test.sh
+++ b/src/test/shell/integration/outputs_test.sh
@@ -72,7 +72,7 @@
mkdir -p $pkg || fail "mkdir -p $pkg failed"
cat >$pkg/rule.bzl <<EOF
def _impl(ctx):
- ctx.file_action(
+ ctx.actions.write(
output=ctx.outputs.out,
content="Hello World!"
)
@@ -110,7 +110,7 @@
}
def _impl(ctx):
- ctx.file_action(
+ ctx.actions.write(
output=ctx.outputs.out,
content="Hello World!"
)
@@ -141,7 +141,7 @@
mkdir -p $pkg || fail "mkdir -p $pkg failed"
cat >$pkg/rule.bzl <<EOF
def _impl(ctx):
- ctx.file_action(
+ ctx.actions.write(
output=ctx.outputs.out,
content="Hello World!"
)
@@ -178,7 +178,7 @@
mkdir -p $pkg || fail "mkdir -p $pkg failed"
cat >$pkg/rule.bzl <<EOF
def _impl(ctx):
- ctx.file_action(
+ ctx.actions.write(
output=ctx.outputs.out,
content="Hello World!"
)