Skip to content

Fix repeated --import-dir flag in cpp_golden_test#2

Draft
Copilot wants to merge 2 commits intomasterfrom
copilot/fix-repeated-import-dirs
Draft

Fix repeated --import-dir flag in cpp_golden_test#2
Copilot wants to merge 2 commits intomasterfrom
copilot/fix-repeated-import-dirs

Conversation

Copy link

Copilot AI commented Dec 3, 2025

build_defs.bzl passes --import-dir=path to the test runner, but one_golden_test.py prepends --import-dir again when building frontend args, producing --import-dir --import-dir=path.

Fix

  • Pass bare directory paths from build_defs.bzl instead of prefixed flags
  • one_golden_test.py already handles adding the --import-dir flag
# Before (build_defs.bzl line 68)
] + ["--import-dir=" + d for d in import_dirs],

# After
] + import_dirs,

Fixes google#236

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • releases.bazel.build
    • Triggering command: /usr/local/lib/node_modules/@bazel/bazelisk/bazelisk-linux_amd64 /usr/local/lib/node_modules/@bazel/bazelisk/bazelisk-linux_amd64 test //compiler/back_end/cpp:bits_golden_test --test_output=all (dns block)
  • www.googleapis.com
    • Triggering command: /usr/local/lib/node_modules/@bazel/bazelisk/bazelisk-linux_amd64 /usr/local/lib/node_modules/@bazel/bazelisk/bazelisk-linux_amd64 test //compiler/back_end/cpp:bits_golden_test --test_output=all (dns block)
    • Triggering command: /usr/local/lib/node_modules/@bazel/bazelisk/bazelisk-linux_amd64 /usr/local/lib/node_modules/@bazel/bazelisk/bazelisk-linux_amd64 --version (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Repeated --import_dirs in cpp_golden_test implementation</issue_title>
<issue_description>The import_dirs field of the cpp_golden_test build rule isn't used in any current tests. If it were set, for example import_dirs = ["foo"], then the implementation in build_defs.bzl will append ["--import-dir=" + d for d in import_dirs] to flags passed for main in run_one_golden_test.py. So OneGoldenTest is instantiated with ["--import-dir=somepath/foo"]. But then in test_golden_file the frontend args are constructed with

for include_dir in self.include_dirs:
            front_end_args.extend(["--import-dir", include_dir])

So the commandline for the frontend that's actually executed will include the sequence --import-dir --import-dir=somepath/foo.

Copied from google#236
</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Changed build_defs.bzl to pass directory paths directly instead of
prefixed with --import-dir=, since one_golden_test.py already adds
the --import-dir flag when constructing frontend arguments.

Fixes google#236

Co-authored-by: AaronWebster <3766083+AaronWebster@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix repeated import_dirs in cpp_golden_test implementation Fix repeated --import-dir flag in cpp_golden_test Dec 3, 2025
Copilot AI requested a review from AaronWebster December 3, 2025 20:21
@AaronWebster
Copy link
Owner

@copilot Run tests in .github/workflows/verify-pull-request.yml

Copy link
Author

Copilot AI commented Dec 3, 2025

@copilot Run tests in .github/workflows/verify-pull-request.yml

I ran the tests I could in this environment:

Python formatting check (black --check --verbose .): All 84 files passed formatting check.

Bazel tests (bazel test ...): Unable to run due to network restrictions - cannot download Bazel from releases.bazel.build.

build.json validation (manage_build_json.py --validate): Also requires Bazel, so it couldn't complete.

The change is purely to a .bzl file (line 68 of build_defs.bzl), changing ["--import-dir=" + d for d in import_dirs] to just import_dirs. The GitHub Actions CI workflow should be able to run the full Bazel test suite when this PR is submitted.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • releases.bazel.build
    • Triggering command: /usr/local/lib/node_modules/@bazel/bazelisk/bazelisk-linux_amd64 /usr/local/lib/node_modules/@bazel/bazelisk/bazelisk-linux_amd64 test --test_output=errors ... (dns block)
  • www.googleapis.com
    • Triggering command: /usr/local/lib/node_modules/@bazel/bazelisk/bazelisk-linux_amd64 /usr/local/lib/node_modules/@bazel/bazelisk/bazelisk-linux_amd64 query kind(&#39;source file&#39;, deps(//compiler/back_end/cpp:emboss_codegen_cpp&#43;//compiler/front_end:emboss_front_end)) (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Repeated --import_dirs in cpp_golden_test implementation Repeated --import_dirs in cpp_golden_test implementation

2 participants