test_action_conflict no longer relies on cc_binary internals
This test previously depended on cc_binary generation of .pic files, which will not be applicable for osx architectures.
RELNOTES: None.
@@ -248,16 +248,45 @@ EOF
# Action conflicts can cause deletion of nodes, and deletion is tricky with no edges.
function test_action_conflict() {
mkdir -p conflict || fail "Couldn't create directory"
+
+ cat > conflict/conflict_rule.bzl <<EOF || fail "Couldn't write bzl file"
+def _create(ctx):
+ files_to_build = set(ctx.outputs.outs)
+ intemediate_outputs = [ctx.new_file("bar")]
+ intermediate_cmd = "cat %s > %s" % (ctx.attr.name, intemediate_outputs[0].path)
+ action_cmd = "touch " + list(files_to_build)[0].path
+ ctx.action(outputs=list(intemediate_outputs),
+ command=intermediate_cmd)
+ ctx.action(inputs=list(intemediate_outputs),
+ outputs=list(files_to_build),
+ command=action_cmd)
+ struct(files=files_to_build,
+ data_runfiles=ctx.runfiles(transitive_files=files_to_build))
+
+conflict = rule(
+ implementation=_create,
+ attrs={
+ "outs": attr.output_list(mandatory=True),
+ },
+ )
+EOF
+
+ mkdir -p conflict || fail "Couldn't create directory"
cat > conflict/BUILD <<EOF || fail "Couldn't create BUILD file"
-cc_library(name='x', srcs=['foo.cc'])
-cc_binary(name='_objs/x/conflict/foo.pic.o', srcs=['bar.cc'])
-cc_binary(name='foo', deps=['x'], data=['_objs/x/conflict/foo.pic.o'])
+load("//conflict:conflict_rule.bzl", "conflict")
+
+conflict(name='hello', outs=['hello_out'])
+conflict(name='goodbye', outs=['goodbye_out'])
+genrule(name='foo',
+ srcs = ['hello_out', 'goodbye_out'],
+ outs = ['foo_out'],
+ cmd = 'touch $@')
+
EOF
- touch conflict/foo.cc || fail
- touch conflict/bar.cc || fail
# --nocache_test_results to make log-grepping easier.
- bazel $STARTUP_FLAGS test $BUILD_FLAGS --nocache_test_results //conflict:foo //testing:mytest >& $TEST_log \
+ bazel $STARTUP_FLAGS test $BUILD_FLAGS \
+ --nocache_test_results //conflict:foo //testing:mytest >& $TEST_log \
&& fail "Expected failure"
exit_code=$?
[ $exit_code -eq 1 ] || fail "Wrong exit code: $exit_code"
