Skip to content

Commit

Permalink
chore: code review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeagle committed Jan 27, 2022
1 parent 0bb1222 commit 8d02c0b
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 16 deletions.
3 changes: 3 additions & 0 deletions docs/Jasmine.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,15 @@ Defaults to `None`
<h4 id="jasmine_node_test-jasmine">jasmine</h4>

A label providing the `@bazel/jasmine` npm dependency.
Intended for internal use only.

Defaults to `None`

<h4 id="jasmine_node_test-jasmine_entry_point">jasmine_entry_point</h4>

A label providing the `@bazel/jasmine` entry point.
This is a custom wrapper which adds features like sharding and ibazel support.
Intended for internal use only.

Defaults to `None`

Expand Down
12 changes: 8 additions & 4 deletions internal/npm_install/generate_build_file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -411,13 +411,17 @@ async function generatePackageBuildFiles(pkg: Dep) {


const indexFile = printIndexBzl(pkg);
const indexFileName = hasIndexBzl ? 'private.bzl' : 'index.bzl'
if (indexFile.length) {
await writeFile(path.posix.join(pkg._dir, indexFileName), indexFile);
buildFile += `
await writeFile(path.posix.join(pkg._dir, hasIndexBzl ? 'private' : '', 'index.bzl'), indexFile);
const buildContent = `
# For integration testing
exports_files(["${indexFileName}"])
exports_files(["index.bzl"])
`;
if (hasIndexBzl) {
await writeFile(path.posix.join(pkg._dir, 'private', 'BUILD.bazel'), buildContent);
} else {
buildFile += buildContent;
}
}


Expand Down
13 changes: 9 additions & 4 deletions internal/npm_install/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,13 +268,18 @@ async function generatePackageBuildFiles(pkg) {
}, Promise.resolve());
}
const indexFile = printIndexBzl(pkg);
const indexFileName = hasIndexBzl ? 'private.bzl' : 'index.bzl';
if (indexFile.length) {
await writeFile(path.posix.join(pkg._dir, indexFileName), indexFile);
buildFile += `
await writeFile(path.posix.join(pkg._dir, hasIndexBzl ? 'private' : '', 'index.bzl'), indexFile);
const buildContent = `
# For integration testing
exports_files(["${indexFileName}"])
exports_files(["index.bzl"])
`;
if (hasIndexBzl) {
await writeFile(path.posix.join(pkg._dir, 'private', 'BUILD.bazel'), buildContent);
}
else {
buildFile += buildContent;
}
}
if (!symlinkBuildFile) {
await writeFile(path.posix.join(pkg._dir, buildFilePath), generateBuildFileHeader(visibility) + buildFile);
Expand Down
3 changes: 0 additions & 3 deletions packages/jasmine/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,6 @@ pkg_npm(
"package.json",
],
build_file_content = "",
substitutions = {
"//packages/jasmine/private:jasmine_runner_test.bzl": "//@bazel/jasmine:private.bzl",
},
deps = [
":README.md",
":npm_version_check",
Expand Down
11 changes: 8 additions & 3 deletions packages/jasmine/jasmine_node_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ than launching a test in Karma, for example.
"""

load("@rules_nodejs//nodejs:providers.bzl", "JSModuleInfo")
load("//packages/jasmine/private:jasmine_runner_test.bzl", "jasmine_runner_test")
load("//packages/jasmine/private:index.bzl", "bazel_jasmine_runner_test")
load("@build_bazel_rules_nodejs//internal/node:node.bzl", nodejs_test = "nodejs_test_macro")

def _js_sources_impl(ctx):
Expand Down Expand Up @@ -67,7 +67,7 @@ def jasmine_node_test(
tags = [],
config_file = None,
use_direct_specs = None,
# Kept for backward compatibility
# TODO(6.0): remove these two attributes, users should never interact with them
jasmine = None,
jasmine_entry_point = None,
**kwargs):
Expand Down Expand Up @@ -103,7 +103,12 @@ def jasmine_node_test(
More info: https://github.com/bazelbuild/rules_nodejs/pull/2576
jasmine: A label providing the `@bazel/jasmine` npm dependency.
Intended for internal use only.
jasmine_entry_point: A label providing the `@bazel/jasmine` entry point.
This is a custom wrapper which adds features like sharding and ibazel support.
Intended for internal use only.
**kwargs: Remaining arguments are passed to the test rule
"""
if kwargs.pop("coverage", False):
Expand Down Expand Up @@ -161,4 +166,4 @@ def jasmine_node_test(
**kwargs
)
else:
jasmine_runner_test(**kwargs)
bazel_jasmine_runner_test(**kwargs)
2 changes: 1 addition & 1 deletion packages/jasmine/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"bazel"
],
"bin": {
"jasmine_runner": "jasmine_runner.js"
"bazel-jasmine-runner": "jasmine_runner.js"
},
"main": "index.js",
"dependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ from rnj sources and should not be published.

load("@build_bazel_rules_nodejs//internal/node:node.bzl", nodejs_test = "nodejs_test_macro")

def jasmine_runner_test(**kwargs):
def bazel_jasmine_runner_test(**kwargs):
nodejs_test(
entry_point = "//packages/jasmine:jasmine_runner.js",
data = ["//packages/jasmine"] + kwargs.pop("data", []),
Expand Down

0 comments on commit 8d02c0b

Please sign in to comment.