-
-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add BAZEL env variable to js_binary
- Loading branch information
1 parent
300f99e
commit 575aa48
Showing
7 changed files
with
110 additions
and
5 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
load("//js:defs.bzl", "js_test") | ||
|
||
js_test( | ||
name = "env_test", | ||
entry_point = "env_test.mjs", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
// Many of these env variables are set by Bazel. See https://bazel.build/reference/test-encyclopedia#initial-conditions. | ||
const expected = { | ||
BAZEL_TEST: '1', | ||
BAZEL: '1', | ||
JS_BINARY__BINDIR: /^bazel-out\/[a-z0-9\-]+\/bin$/, | ||
JS_BINARY__BUILD_FILE_PATH: 'js/private/test/env/BUILD.bazel', | ||
JS_BINARY__COMPILATION_MODE: /.+/, | ||
JS_BINARY__COPY_DATA_TO_BIN: '1', | ||
JS_BINARY__EXECROOT: /.+/, | ||
JS_BINARY__FS_PATCH_ROOTS: /.+/, | ||
JS_BINARY__LOG_ERROR: '1', | ||
JS_BINARY__LOG_FATAL: '1', | ||
JS_BINARY__LOG_PREFIX: 'aspect_rules_js[js_test]', | ||
JS_BINARY__NODE_BINARY: /bin\/nodejs\/bin\/node$/, | ||
JS_BINARY__NODE_PATCHES_DEPTH: '.', | ||
JS_BINARY__NODE_PATCHES: | ||
/bazel-out\/[a-z0-9\-]+\/bin\/js\/private\/test\/env\/env_test.sh.runfiles\/[a-z_]+\/js\/private\/node-patches\/register\.js$/, | ||
JS_BINARY__NODE_WRAPPER: | ||
/bazel-out\/[a-z0-9\-]+\/bin\/js\/private\/test\/env\/env_test.sh.runfiles\/[a-z_]+\/js\/private\/test\/env\/env_test_node_bin\/node$/, | ||
JS_BINARY__PACKAGE: 'js/private/test/env', | ||
JS_BINARY__PATCH_NODE_FS: '1', | ||
JS_BINARY__RUNFILES: | ||
/bazel-out\/[a-z0-9\-]+\/bin\/js\/private\/test\/env\/env_test\.sh\.runfiles$/, | ||
JS_BINARY__TARGET_CPU: /.+/, | ||
JS_BINARY__TARGET_NAME: 'env_test', | ||
JS_BINARY__TARGET: '//js/private/test/env:env_test', | ||
JS_BINARY__WORKSPACE: /[a-z_]+/, | ||
RUNFILES_DIR: | ||
/bazel-out\/[a-z0-9\-]+\/bin\/js\/private\/test\/env\/env_test\.sh\.runfiles$/, | ||
RUNFILES: | ||
/bazel-out\/[a-z0-9\-]+\/bin\/js\/private\/test\/env\/env_test\.sh\.runfiles$/, | ||
TEST_BINARY: 'js/private/test/env/env_test.sh', | ||
TEST_INFRASTRUCTURE_FAILURE_FILE: | ||
/bazel-out\/[a-z0-9\-]+\/testlogs\/js\/private\/test\/env\/env_test\/test\.infrastructure_failure$/, | ||
TEST_LOGSPLITTER_OUTPUT_FILE: | ||
/bazel-out\/[a-z0-9\-]+\/testlogs\/js\/private\/test\/env\/env_test\/test\.raw_splitlogs\/test\.splitlogs$/, | ||
TEST_PREMATURE_EXIT_FILE: | ||
/bazel-out\/[a-z0-9\-]+\/testlogs\/js\/private\/test\/env\/env_test\/test\.exited_prematurely$/, | ||
TEST_SIZE: 'medium', | ||
TEST_SRCDIR: | ||
/bazel-out\/[a-z0-9\-]+\/bin\/js\/private\/test\/env\/env_test\.sh\.runfiles$/, | ||
TEST_TARGET: '//js/private/test/env:env_test', | ||
TEST_TIMEOUT: /[0-9]+/, | ||
TEST_TMPDIR: /.+/, | ||
TEST_UNDECLARED_OUTPUTS_ANNOTATIONS_DIR: | ||
/bazel-out\/[a-z0-9\-]+\/testlogs\/js\/private\/test\/env\/env_test\/test\.outputs_manifest$/, | ||
TEST_UNDECLARED_OUTPUTS_DIR: | ||
/bazel-out\/[a-z0-9\-]+\/testlogs\/js\/private\/test\/env\/env_test\/test\.outputs$/, | ||
TEST_UNUSED_RUNFILES_LOG_FILE: | ||
/bazel-out\/[a-z0-9\-]+\/testlogs\/js\/private\/test\/env\/env_test\/test\.unused_runfiles_log$/, | ||
TEST_WARNINGS_OUTPUT_FILE: | ||
/bazel-out\/[a-z0-9\-]+\/testlogs\/js\/private\/test\/env\/env_test\/test\.warnings$/, | ||
TEST_WORKSPACE: /[a-z_]+/, | ||
XML_OUTPUT_FILE: | ||
/bazel-out\/[a-z0-9\-]+\/testlogs\/js\/private\/test\/env\/env_test\/test\.xml$/, | ||
} | ||
|
||
let failed = false | ||
for (const k of Object.keys(expected)) { | ||
const v = expected[k] | ||
if (typeof v === 'string') { | ||
if (process.env[k] !== v) { | ||
console.error( | ||
`Expected environment variable ${k} to equal '${v}' but got '${process.env[k]}' instead` | ||
) | ||
failed = true | ||
} | ||
} else { | ||
if (!process.env[k].match(v)) { | ||
console.error( | ||
`Expected environment variable ${k} to match regex ${v} but value '${process.env[k]}' does not match` | ||
) | ||
failed = true | ||
} | ||
} | ||
} | ||
if (failed) { | ||
process.exit(1) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
b44c02668701d4db8430edae7d6f6ecede824e704d5c46226e2b32cc20633407 | ||
07c98625ac9e18c33bcf6d5562ab092abe470847437571e2a0b02af39932fc60 | ||
f68066745a57eff40fc49b4600cdde860dfa86ab231ebe4ed65097c98cc2df4f |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters