Skip to content

test(bzlmod): Make some tests bzlmod compatible with Bazel@HEAD#1482

Merged
rickeylev merged 3 commits intobazel-contrib:mainfrom
rickeylev:bzlmod-default
Oct 11, 2023
Merged

test(bzlmod): Make some tests bzlmod compatible with Bazel@HEAD#1482
rickeylev merged 3 commits intobazel-contrib:mainfrom
rickeylev:bzlmod-default

Conversation

@rickeylev
Copy link
Copy Markdown
Collaborator

A few tests weren't compatible with bzlmod, so would fail when it was enabled. The various causes and fixes are:

  • Under bzlmod, runfiles.CurrentRepository() returns the empty string for the main repository. To fix, an environment variable is used to tell the test whether bzlmod is enabled or not.

  • Accessing data files through TEST_SRCDIR directly is error-prone under bzlmod because the directory name within runfiles changes from the workspace name to _main. To fix, use the runfiles libraries, which know how to map apparent repo names to the actual directory name. In the integration tests, the runfiles library isn't available, so just check for the _main directory instead.

Work towards #1469

A few tests weren't compatible with bzlmod, so would fail when it was
enabled. The various causes and fixes are:

* Under bzlmod, `runfiles.CurrentRepository()` returns the empty string
  for the main repository. To fix, an environment variable is used to
  tell the test whether bzlmod is enabled or not.

* Accessing data files through `TEST_SRCDIR` directly is error-prone
  under bzlmod because the directory name within runfiles changes from
  the workspace name to `_main`. To fix, use the runfiles libraries,
  which know how to map apparent repo names to the actual directory
  name. In the integration tests, the runfiles library isn't available,
  so just check for the `_main` directory instead.

Work towards bazel-contrib#1469
@rickeylev rickeylev enabled auto-merge October 11, 2023 04:35
@rickeylev rickeylev added this pull request to the merge queue Oct 11, 2023
Merged via the queue into bazel-contrib:main with commit cf3cdc1 Oct 11, 2023
@rickeylev rickeylev deleted the bzlmod-default branch December 19, 2023 01:15
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.

2 participants