Skip to content

Commit 397ea00

Browse files
committed
build: migrate @angular-devkit/architect/node tests to rules_js
Migrates the sub-entry point tests for architect/node to `rules_js`.
1 parent e01b4f6 commit 397ea00

File tree

7 files changed

+31
-34
lines changed

7 files changed

+31
-34
lines changed

packages/angular_devkit/architect/node/BUILD.bazel

+5-7
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
# Use of this source code is governed by an MIT-style license that can be
44
# found in the LICENSE file at https://angular.dev/license
55

6-
load("@npm//@bazel/jasmine:index.bzl", "jasmine_node_test")
7-
load("//tools:interop.bzl", "ts_project")
6+
load("//tools:defaults2.bzl", "jasmine_test", "ts_project")
87

98
licenses(["notice"])
109

@@ -21,8 +20,7 @@ ts_project(
2120
"//:node_modules/@types/node",
2221
"//:node_modules/rxjs",
2322
"//packages/angular_devkit/architect:architect_rjs",
24-
"//packages/angular_devkit/core:core_rjs",
25-
"//packages/angular_devkit/core/node:node_rjs",
23+
"//packages/angular_devkit/architect:node_modules/@angular-devkit/core",
2624
],
2725
)
2826

@@ -39,11 +37,11 @@ ts_project(
3937
"//:node_modules/@types/jasmine",
4038
"//:node_modules/rxjs",
4139
"//packages/angular_devkit/architect:architect_rjs",
42-
"//tests/angular_devkit/architect/node/jobs:jobs_test_lib_rjs",
40+
"//packages/angular_devkit/architect/node/test:test_lib_rjs",
4341
],
4442
)
4543

46-
jasmine_node_test(
44+
jasmine_test(
4745
name = "node_test",
48-
srcs = [":node_test_lib"],
46+
data = [":node_test_lib_rjs"],
4947
)

packages/angular_devkit/architect/node/jobs/job-registry.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* found in the LICENSE file at https://angular.dev/license
77
*/
88

9-
import { jobs } from '@angular-devkit/architect';
9+
import { jobs } from '../../src';
1010
import { JsonValue, schema } from '@angular-devkit/core';
1111
import { Observable, of } from 'rxjs';
1212

packages/angular_devkit/architect/node/jobs/job-registry_spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
* found in the LICENSE file at https://angular.dev/license
77
*/
88

9-
import { jobs } from '@angular-devkit/architect';
109
import * as path from 'path';
1110
import { lastValueFrom } from 'rxjs';
1211
import { NodeModuleJobRegistry } from './job-registry';
12+
import { jobs } from '../../src';
1313

14-
const root = path.join(__dirname, '../../../../../tests/angular_devkit/architect/node/jobs');
14+
const root = path.join(__dirname, '../test/jobs');
1515

1616
describe('NodeModuleJobScheduler', () => {
1717
it('works', async () => {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
load("//tools:interop.bzl", "ts_project")
2+
3+
ts_project(
4+
name = "test_lib",
5+
srcs = glob(["**/*.ts"]),
6+
visibility = ["//packages/angular_devkit/architect/node:__pkg__"],
7+
deps = [
8+
"//:node_modules/@types/node",
9+
"//packages/angular_devkit/architect:architect_rjs",
10+
],
11+
)

tests/angular_devkit/architect/node/jobs/add.ts renamed to packages/angular_devkit/architect/node/test/jobs/add.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* found in the LICENSE file at https://angular.dev/license
77
*/
88

9-
import { jobs } from '@angular-devkit/architect';
9+
import { jobs } from '../../../index';
1010

1111
// Export the job using a createJob. We use our own spec file here to do the job.
1212
export default jobs.createJobHandler<number[], null, number>(

tests/angular_devkit/architect/node/jobs/BUILD.bazel

-22
This file was deleted.

tools/interop.bzl

+11-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,14 @@ ts_project_module = rule(
9797
},
9898
)
9999

100-
def ts_project(name, module_name = None, deps = [], tsconfig = None, testonly = False, **kwargs):
100+
def ts_project(
101+
name,
102+
module_name = None,
103+
deps = [],
104+
tsconfig = None,
105+
testonly = False,
106+
visibility = None,
107+
**kwargs):
101108
interop_deps = []
102109

103110
# Pull in the `rules_nodejs` variants of dependencies we know are "hybrid". This
@@ -118,6 +125,7 @@ def ts_project(name, module_name = None, deps = [], tsconfig = None, testonly =
118125
ts_deps_interop(
119126
name = "%s_interop_deps" % name,
120127
deps = [] + interop_deps + rjs_modules_to_rnjs,
128+
visibility = visibility,
121129
testonly = testonly,
122130
)
123131

@@ -126,6 +134,7 @@ def ts_project(name, module_name = None, deps = [], tsconfig = None, testonly =
126134
testonly = testonly,
127135
declaration = True,
128136
tsconfig = tsconfig,
137+
visibility = visibility,
129138
# Use the worker from our own Angular rules, as the default worker
130139
# from `rules_ts` is incompatible with TS5+ and abandoned. We need
131140
# worker for efficient, fast DX and avoiding Windows no-sandbox issues.
@@ -138,6 +147,7 @@ def ts_project(name, module_name = None, deps = [], tsconfig = None, testonly =
138147
ts_project_module(
139148
name = name,
140149
testonly = testonly,
150+
visibility = visibility,
141151
dep = "%s_rjs" % name,
142152
# Forwarded dependencies for linker module mapping aspect.
143153
# RJS deps can also transitively pull in module mappings from their `interop_deps`.

0 commit comments

Comments
 (0)