Skip to content
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

fix: windows file URL issue #148

Merged
merged 1 commit into from
Jul 12, 2023
Merged
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
28 changes: 26 additions & 2 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,28 @@
# Bazel settings that apply to this repository.
# Take care to document any settings that you expect users to apply.
# Settings that apply only to CI are in .github/workflows/ci.bazelrc

# Bazel picks up host-OS-specific config lines from bazelrc files. For example, if the host OS is
# Linux and you run bazel build, Bazel picks up lines starting with build:linux. Supported OS
# identifiers are `linux`, `macos`, `windows`, `freebsd`, and `openbsd`. Enabling this flag is
# equivalent to using `--config=linux` on Linux, `--config=windows` on Windows, etc.
# Docs: https://bazel.build/reference/command-line-reference#flag--enable_platform_specific_config
common --enable_platform_specific_config

# Required by rules_js
build --enable_runfiles

build --incompatible_strict_action_env
build --nolegacy_external_runfiles
# required for rules_js
build --enable_runfiles

# Filter out tests depending on platform
test:windows --test_tag_filters=-no-windows

# Load any settings specific to the current user.
# .bazelrc.user should appear in .gitignore so that settings are not shared with team members
# This needs to be last statement in this
# config, as the user configuration should be able to overwrite flags from this file.
# See https://docs.bazel.build/versions/master/best-practices.html#bazelrc
# (Note that we use .bazelrc.user so the file appears next to .bazelrc in directory listing,
# rather than user.bazelrc as suggested in the Bazel docs)
try-import %workspace%/.bazelrc.user
9 changes: 8 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,14 @@ jobs:
uses: bazel-contrib/.github/.github/workflows/bazel.yaml@v2
with:
folders: '[".", "e2e/npm_packages", "e2e/smoke"]'

exclude: |
[
{"bazelversion": "5.4.0", "bzlmodEnabled": true},
{"bazelversion": "5.4.0", "os": "macos-latest"},
{"bazelversion": "5.4.0", "os": "windows-latest"},
{"folder": ".", "os": "windows-latest"},
{"folder": "e2e/npm_packages", "os": "windows-latest"},
]
test-e2e:
runs-on: ubuntu-latest
steps:
Expand Down
14 changes: 14 additions & 0 deletions e2e/smoke/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,18 @@ jest_test(
config = "jest.config.js",
data = ["index.test.js"],
node_modules = "//:node_modules",
# jest does not find tests on Windows; it appears the fix in https://github.com/jestjs/jest/pull/9351
# for discovering tests when they are symlinks does not work on Windows.
tags = ["no-windows"],
)

jest_test(
name = "by_path_test",
args = [
"--runTestsByPath",
"index.test.js",
],
config = "jest.config.js",
data = ["index.test.js"],
node_modules = "//:node_modules",
)
8 changes: 6 additions & 2 deletions jest/private/jest_config_template.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,18 @@ function _addReporter(config, name, reporter = undefined) {
let config = {};
if (userConfigShortPath) {
if (path.extname(userConfigShortPath).toLowerCase() == ".json") {
// On Windows, import does not like paths that start with the drive letter such as
// `c:\...` so we prepend the with `file://` so node is happy.
config = (
await import(_resolveRunfilesPath(userConfigShortPath), {
await import("file://" + _resolveRunfilesPath(userConfigShortPath), {
assert: { type: "json" },
})
).default;
} else {
// On Windows, import does not like paths that start with the drive letter such as
// `c:\...` so we prepend the with `file://` so node is happy.
const userConfigModule = (
await import(_resolveRunfilesPath(userConfigShortPath))
await import("file://" + _resolveRunfilesPath(userConfigShortPath))
).default;
if (typeof userConfigModule === "function") {
config = await userConfigModule();
Expand Down