-
Notifications
You must be signed in to change notification settings - Fork 8
test: Construct a test for running in the cwd.
#112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
This doesn't work for me -- this test is a reproduction of the `:cwd` target for a multitool not finding the `tool`.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| 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", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 👍 / 👎.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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."
Running
:cwdin agenruledoesn't find the tool -- it reports afile not founderror.