Skip to content

Commit 612c178

Browse files
committed
build: migrate @angular-devkit/schematics/tools tests to rules_js
Migrates the sub-entry point tests for schematics/tools to `rules_js`.
1 parent 1aa943c commit 612c178

File tree

4 files changed

+11
-27
lines changed

4 files changed

+11
-27
lines changed

packages/angular_devkit/schematics/tools/BUILD.bazel

+5-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
load("@npm//@bazel/jasmine:index.bzl", "jasmine_node_test")
2-
load("//tools:interop.bzl", "ts_project")
1+
load("//tools:defaults2.bzl", "jasmine_test", "ts_project")
32

43
# Copyright Google Inc. All Rights Reserved.
54
#
@@ -24,8 +23,7 @@ ts_project(
2423
"//:node_modules/@types/node",
2524
"//:node_modules/jsonc-parser",
2625
"//:node_modules/rxjs",
27-
"//packages/angular_devkit/core:core_rjs",
28-
"//packages/angular_devkit/core/node:node_rjs",
26+
"//packages/angular_devkit/schematics:node_modules/@angular-devkit/core",
2927
"//packages/angular_devkit/schematics:schematics_rjs",
3028
"//packages/angular_devkit/schematics/tasks:tasks_rjs",
3129
"//packages/angular_devkit/schematics/tasks/node:node_rjs",
@@ -45,16 +43,15 @@ ts_project(
4543
":tools_rjs",
4644
"//:node_modules/@types/jasmine",
4745
"//:node_modules/rxjs",
48-
"//packages/angular_devkit/core:core_rjs",
49-
"//packages/angular_devkit/core/node:node_rjs",
46+
"//packages/angular_devkit/schematics:node_modules/@angular-devkit/core",
5047
"//packages/angular_devkit/schematics:schematics_rjs",
5148
"//packages/angular_devkit/schematics/tasks:tasks_rjs",
5249
"//packages/angular_devkit/schematics/testing:testing_rjs",
5350
"//tests/angular_devkit/schematics/tools/file-system-engine-host:file_system_engine_host_test_lib_rjs",
5451
],
5552
)
5653

57-
jasmine_node_test(
54+
jasmine_test(
5855
name = "tools_test",
59-
deps = [":tools_test_lib"],
56+
data = [":tools_test_lib_rjs"],
6057
)

packages/angular_devkit/schematics/tools/file-system-engine-host_spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88

99
/* eslint-disable @typescript-eslint/no-explicit-any, import/no-extraneous-dependencies */
1010
import { normalize, virtualFs } from '@angular-devkit/core';
11-
import { HostSink, HostTree, SchematicEngine } from '@angular-devkit/schematics';
12-
import { FileSystemEngineHost } from '@angular-devkit/schematics/tools';
1311
import * as path from 'path';
1412
import { from, lastValueFrom, of as observableOf } from 'rxjs';
13+
import { HostSink, HostTree, SchematicEngine } from '../index';
14+
import { FileSystemEngineHost } from './file-system-engine-host';
1515

1616
describe('FileSystemEngineHost', () => {
1717
// We need to resolve a file that actually exists, and not just a folder.

packages/angular_devkit/schematics/tools/node-module-engine-host_spec.ts

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

9-
import { SchematicEngine } from '@angular-devkit/schematics';
109
import * as fs from 'fs';
1110
import * as os from 'os';
1211
import * as path from 'path';
12+
import { SchematicEngine } from '../index';
1313
import { NodeModulesEngineHost } from './node-module-engine-host';
1414

1515
const TMP_DIR = process.env['TEST_TMPDIR'] || os.tmpdir();
1616

1717
describe('NodeModulesEngineHost', () => {
1818
let tmpDir!: string;
19-
let previousDir!: string;
2019

2120
beforeEach(() => {
2221
tmpDir = fs.mkdtempSync(
2322
path.join(TMP_DIR, 'angular-devkit-schematics-tools-node-module-engine-host'),
2423
);
25-
previousDir = process.cwd();
26-
process.chdir(tmpDir);
2724
});
2825

29-
afterEach(() => process.chdir(previousDir));
30-
3126
/** Creates a fake NPM module that can be used to test the node module engine host. */
3227
function createFakeNpmModule() {
3328
fs.mkdirSync(path.join(tmpDir, 'node_modules'));
@@ -47,19 +42,11 @@ describe('NodeModulesEngineHost', () => {
4742
it('should properly create collections with explicit collection path', () => {
4843
createFakeNpmModule();
4944

50-
const engineHost = new NodeModulesEngineHost();
45+
const engineHost = new NodeModulesEngineHost([tmpDir]);
5146
const engine = new SchematicEngine(engineHost);
5247

53-
// Under Bazel 'require.resolve' is patched to use Bazel resolutions from the MANIFEST FILES.
54-
// Adding a temporary file won't be enough to make Bazel aware of this file.
55-
// We provide the full path here just to verify that the underlying logic works
56-
let prefix = '';
57-
if (process.env['BAZEL_TARGET']) {
58-
prefix = path.join(process.cwd(), 'node_modules');
59-
}
60-
6148
expect(() => {
62-
engine.createCollection(path.join(prefix, '@angular/core', './schematics/migrations.json'));
49+
engine.createCollection(path.join('@angular/core', './schematics/migrations.json'));
6350
}).not.toThrow();
6451
});
6552
});

packages/angular_devkit/schematics/tools/workflow/node-workflow_spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
/* eslint-disable import/no-extraneous-dependencies */
1010
import { NodeJsSyncHost } from '@angular-devkit/core/node';
11-
import { NodeWorkflow } from '@angular-devkit/schematics/tools';
1211
import * as path from 'path';
12+
import { NodeWorkflow } from './node-workflow';
1313

1414
describe('NodeWorkflow', () => {
1515
// TODO: this test seems to either not work on windows or on linux.

0 commit comments

Comments
 (0)