blob: da5219ebb94d31d919137ec4c2bc5a6cec9a5a7b [file]
load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_files")
load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@npm//:defs.bzl", "npm_link_all_packages")
load(":transitive_closure_tests.bzl", "transitive_closure_tests")
load(":translate_lock_tests.bzl", "translate_lock_tests")
load(":yaml_tests.bzl", "yaml_tests")
load(":utils_tests.bzl", "utils_tests")
load(":npmrc_test.bzl", "npmrc_tests")
load(":pkg_glob_tests.bzl", "pkg_glob_tests")
load(":generated_pkg_json_test.bzl", "generated_pkg_json_test")
load(":npm_auth_test.bzl", "npm_auth_test_suite")
# gazelle:exclude *_checked.bzl
npm_link_all_packages(name = "node_modules")
# Unit tests
utils_tests(name = "test_utils")
npmrc_tests(name = "test_npmrc")
pkg_glob_tests(name = "test_pkg_glob")
transitive_closure_tests(name = "test_transitive_closure")
translate_lock_tests(name = "test_translate_lock")
yaml_tests(name = "test_yaml")
generated_pkg_json_test(name = "test_generated_pkg_json")
npm_auth_test_suite()
write_source_files(
name = "write_npm_translate_lock",
files = {
"repositories_checked.bzl": "@npm//:repositories.bzl",
"package_json_checked.bzl": "@npm__rollup__2.70.2//examples/npm_deps:package_json.bzl",
"package_json_with_dashes_checked.bzl": "@npm__webpack-bundle-analyzer__4.5.0__bufferutil_4.0.7//npm/private/test:package_json.bzl",
},
)
build_test(
name = "node_modules_test",
targets = [
":node_modules/@blockprotocol/type-system-web",
":node_modules/@figma/nodegit",
# @kubernetes/client-node has a "prepare" lifecycle hook that runs tsc
":node_modules/@kubernetes/client-node",
":node_modules/@plotly/regl",
":node_modules/bufferutil",
":node_modules/debug",
":node_modules/esbuild",
":node_modules/handlebars-helpers/helper-date",
":node_modules/inline-fixtures",
":node_modules/json-stable-stringify",
# a vendored .tgz file
":node_modules/lodash",
":node_modules/node-gyp",
":node_modules/plotly.js",
":node_modules/protoc-gen-grpc",
":node_modules/regl",
# segfault-handler has a node-gyp install step
":node_modules/segfault-handler",
":node_modules/semver-first-satisfied",
":node_modules/typescript",
# intentionally don't include node_modules/unused
":node_modules/webpack-bundle-analyzer",
],
)
sh_test(
name = "bin_test",
srcs = ["bin_test.sh"],
args = ["$(NODE_PATH)"],
data = [
# Test that node_modules/.bin binaries work in both the root package
# and in subpackages. The relative paths in the two are different since the
# actual node entry is in the virtual store which is in the root package.
"//:node_modules/typescript",
":node_modules/typescript",
# This eager toolchain fetching could be cleaed up in the future
"@nodejs_darwin_amd64//:node_files",
"@nodejs_darwin_arm64//:node_files",
"@nodejs_linux_amd64//:node_files",
"@nodejs_linux_arm64//:node_files",
],
toolchains = ["@nodejs_toolchains//:resolved_toolchain"],
)