Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions examples/module/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@rules_multitool//multitool:cwd.bzl", "cwd")
load("@rules_shell//shell:sh_test.bzl", "sh_test")
load("//:add_dummy_file.bzl", "add_dummy_file")
Expand Down Expand Up @@ -50,3 +51,16 @@ sh_test(
data = [":add_dummy_file_cwd"],
env = {"BUILD_WORKING_DIRECTORY": "."},
)

genrule(
name = "run_gh_alias_import",
srcs = ["test_gh_aliases.yaml"],
outs = ["run_gh_alias_import.out"],
cmd = "$(location @multitool//tools/gh:cwd) alias import test_gh_aliases.yaml && touch run_gh_alias_import.out",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Reference genrule input via $(location)

Building //examples/module:run_gh_alias_import runs gh alias import test_gh_aliases.yaml without a $(location ...) expansion, but genrule commands execute from the output directory and do not stage source files there. In sandboxed or remote builds the YAML won’t be found, so the new build_test will fail every time. Use $(location test_gh_aliases.yaml) (or $(SRCS)) so the command can see its input file.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thi s is intentional because I want the :cwd to find the file in the working directory, simulating a tool that expects a config file in the cwd.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m not sure I understand the issue you’re trying to test — :cwd doesn’t work for you, or config files in the current working directory are not available to you when running using bazel run?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:cwd doesn't work -- the wrapper script gets a file not found error trying to execute the tool when in a genrule or run_binary context.

I expected to be able to use :cwd to say "run the command in the current path, because this program has weird behaviour that expects its config file to exist in the location it's run in."

tools = ["@multitool//tools/gh:cwd"],
)

build_test(
name = "run_gh_alias_import_test",
targets = [":run_gh_alias_import.out"],
)
1 change: 1 addition & 0 deletions examples/module/test_gh_aliases.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bug: issues list --label=bug
Loading