def test_sources_and_files(rule_runner: RuleRunner) -> None: MSG = ["Hello shell_command", ", nice cut."] rule_runner.write_files({ "src/BUILD": dedent("""\ experimental_shell_command( name="hello", dependencies=[":build-utils", ":files"], tools=[ "bash", "cat", "env", "mkdir", "tee", ], outputs=["message.txt", "res/"], command="./script.sh", ) files( name="files", sources=["*.txt"], ) shell_sources(name="build-utils") """), "src/intro.txt": MSG[0], "src/outro.txt": MSG[1], "src/script.sh": ("#!/usr/bin/env bash\n" "mkdir res && cat *.txt > message.txt && cat message.txt | tee res/log.txt" ), }) # Set script.sh mode to rwxr-xr-x. rule_runner.chmod("src/script.sh", 0o755) RES = "".join(MSG) assert_shell_command_result( rule_runner, Address("src", target_name="hello"), expected_contents={ "src/message.txt": RES, "src/res/log.txt": RES, }, )