Skip to content

Commit f30a69f

Browse files
alan-agius4angular-robot[bot]
authored andcommitted
test: remove non bazel related setups
This commits removes some of the non Bazel related checks that are no longer required. This also fixes some issues with `bazel run`
1 parent abcea34 commit f30a69f

File tree

10 files changed

+19
-101
lines changed

10 files changed

+19
-101
lines changed

.circleci/dynamic_config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ workflows:
444444

445445
# Publish jobs
446446
- snapshot_publish:
447-
# <<: *only_release_branches
447+
<<: *only_release_branches
448448
requires:
449449
- setup
450450
- e2e-cli

tests/legacy-cli/BUILD.bazel

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ load(":e2e.bzl", "e2e_suites")
44
ts_library(
55
name = "runner",
66
testonly = True,
7-
srcs = glob(["**/*.ts"]),
7+
srcs = [
8+
"e2e_runner.ts",
9+
],
810
data = [
911
"verdaccio.yaml",
1012
"verdaccio_auth.yaml",

tests/legacy-cli/e2e/initialize/500-create-project.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import { join } from 'path';
22
import yargsParser from 'yargs-parser';
3-
import { IS_BAZEL } from '../utils/bazel';
43
import { getGlobalVariable } from '../utils/env';
54
import { expectFileToExist } from '../utils/fs';
65
import { gitClean } from '../utils/git';
7-
import { installPackage, setRegistry as setNPMConfigRegistry } from '../utils/packages';
6+
import { setRegistry as setNPMConfigRegistry } from '../utils/packages';
87
import { ng } from '../utils/process';
98
import { prepareProjectForE2e, updateJsonFile } from '../utils/project';
109

@@ -22,16 +21,6 @@ export default async function () {
2221
// Ensure local test registry is used when outside a project
2322
await setNPMConfigRegistry(true);
2423

25-
// Install puppeteer in the parent directory for use by the CLI within any test project.
26-
// Align the version with the primary project package.json.
27-
// Bazel has own browser toolchains
28-
// TODO(bazel): remove non-bazel
29-
if (!IS_BAZEL) {
30-
const puppeteerVersion =
31-
require('../../../../package.json').devDependencies.puppeteer.replace(/^[\^~]/, '');
32-
await installPackage(`puppeteer@${puppeteerVersion}`);
33-
}
34-
3524
await ng('new', 'test-project', '--skip-install');
3625
await expectFileToExist(join(process.cwd(), 'test-project'));
3726
process.chdir('./test-project');

tests/legacy-cli/e2e/tests/build/esbuild-unsupported.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import { join } from 'path';
2-
import { IS_BAZEL } from '../../utils/bazel';
32
import { execWithEnv } from '../../utils/process';
43

54
export default async function () {
65
// TODO(bazel): fails with bazel on windows
7-
if (IS_BAZEL && process.platform.startsWith('win')) {
6+
if (process.platform.startsWith('win')) {
87
return;
98
}
109

tests/legacy-cli/e2e/utils/bazel.ts

Lines changed: 0 additions & 3 deletions
This file was deleted.

tests/legacy-cli/e2e/utils/process.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { getGlobalVariable, getGlobalVariablesEnv } from './env';
77
import { catchError } from 'rxjs/operators';
88
import treeKill from 'tree-kill';
99
import { delimiter, join, resolve } from 'path';
10-
import { IS_BAZEL } from './bazel';
1110

1211
interface ExecOptions {
1312
silent?: boolean;
@@ -420,11 +419,7 @@ export async function launchTestProcess(entry: string, ...args: any[]): Promise<
420419
.filter((p) => p.startsWith(tempRoot) || p.startsWith(TEMP) || !p.includes('angular-cli'))
421420
.join(delimiter);
422421

423-
const testProcessArgs = [
424-
resolve(__dirname, IS_BAZEL ? 'test_process' : 'run_test_process'),
425-
entry,
426-
...args,
427-
];
422+
const testProcessArgs = [resolve(__dirname, 'test_process'), entry, ...args];
428423

429424
return new Promise<void>((resolve, reject) => {
430425
spawn(process.execPath, testProcessArgs, {

tests/legacy-cli/e2e/utils/project.ts

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@ import * as fs from 'fs';
22
import * as path from 'path';
33
import { prerelease, SemVer } from 'semver';
44
import yargsParser from 'yargs-parser';
5-
import { IS_BAZEL } from './bazel';
65
import { getGlobalVariable } from './env';
76
import { readFile, replaceInFile, writeFile } from './fs';
87
import { gitCommit } from './git';
98
import { findFreePort } from './network';
109
import { installWorkspacePackages, PkgInfo } from './packages';
11-
import { exec, execAndWaitForOutputToMatch, git, ng } from './process';
10+
import { execAndWaitForOutputToMatch, git, ng } from './process';
1211

1312
export function updateJsonFile(filePath: string, fn: (json: any) => any | void) {
1413
return readFile(filePath).then((tsConfigJson) => {
@@ -51,43 +50,6 @@ export async function prepareProjectForE2e(name: string) {
5150
await installWorkspacePackages();
5251
await ng('generate', 'e2e', '--related-app-name', name);
5352

54-
// bazel will use its own sandboxed browser + webdriver
55-
// TODO(bazel): remove non-bazel
56-
if (!IS_BAZEL) {
57-
const protractorPath = require.resolve('protractor');
58-
const webdriverUpdatePath = require.resolve('webdriver-manager/selenium/update-config.json', {
59-
paths: [protractorPath],
60-
});
61-
const webdriverUpdate = JSON.parse(await readFile(webdriverUpdatePath)) as {
62-
chrome: { last: string };
63-
};
64-
65-
const chromeDriverVersion = webdriverUpdate.chrome.last.match(/chromedriver_([\d|\.]+)/)?.[1];
66-
if (!chromeDriverVersion) {
67-
throw new Error('Could not extract chrome webdriver version.');
68-
}
69-
70-
// Initialize selenium webdriver.
71-
// Often fails the first time so attempt twice if necessary.
72-
const runWebdriverUpdate = () =>
73-
exec(
74-
process.execPath,
75-
'node_modules/protractor/bin/webdriver-manager',
76-
'update',
77-
'--standalone',
78-
'false',
79-
'--gecko',
80-
'false',
81-
'--versions.chrome',
82-
chromeDriverVersion,
83-
);
84-
try {
85-
await runWebdriverUpdate();
86-
} catch {
87-
await runWebdriverUpdate();
88-
}
89-
}
90-
9153
await useCIChrome(name, 'e2e');
9254
await useCIChrome(name, '');
9355
await useCIDefaults(name);

tests/legacy-cli/e2e/utils/run_test_process.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

tests/legacy-cli/e2e_runner.ts

Lines changed: 11 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { logging } from '../../packages/angular_devkit/core/src';
21
import { createConsoleLogger } from '../../packages/angular_devkit/core/node';
32
import * as colors from 'ansi-colors';
43
import glob from 'glob';
@@ -9,10 +8,9 @@ import { gitClean } from './e2e/utils/git';
98
import { createNpmRegistry } from './e2e/utils/registry';
109
import { launchTestProcess } from './e2e/utils/process';
1110
import { delimiter, dirname, join } from 'path';
12-
import { IS_BAZEL } from './e2e/utils/bazel';
1311
import { findFreePort } from './e2e/utils/network';
1412
import { extractFile } from './e2e/utils/tar';
15-
import { readFileSync, realpathSync } from 'fs';
13+
import { realpathSync } from 'fs';
1614
import { PkgInfo } from './e2e/utils/packages';
1715

1816
Error.stackTraceLimit = Infinity;
@@ -57,12 +55,11 @@ const argv = yargsParser(process.argv.slice(2), {
5755
number: ['nb-shards', 'shard'],
5856
array: ['package'],
5957
configuration: {
60-
'dot-notation': false,
6158
'camel-case-expansion': false,
59+
'dot-notation': false,
6260
},
6361
default: {
6462
'package': ['./dist/_*.tgz'],
65-
6663
'debug': !!process.env.BUILD_WORKSPACE_DIRECTORY,
6764
'glob': process.env.TESTBRIDGE_TEST_ONLY,
6865
'nb-shards':
@@ -119,23 +116,19 @@ function lastLogger() {
119116
}
120117

121118
// Under bazel the compiled file (.js) and types (.d.ts) are available.
122-
// Outside bazel the source .ts files are available.
123-
const SRC_FILE_EXT = IS_BAZEL ? 'js' : 'ts';
124-
const SRC_FILE_EXT_RE = new RegExp(`\.${SRC_FILE_EXT}$`);
125-
126-
const testGlob = argv.glob || `tests/**/*.${SRC_FILE_EXT}`;
119+
const SRC_FILE_EXT_RE = /\.js$/;
120+
const testGlob = argv.glob?.replace(/\.ts$/, '.js') || `tests/**/*.js`;
127121

128122
const e2eRoot = path.join(__dirname, 'e2e');
129-
const allSetups = glob.sync(`setup/**/*.${SRC_FILE_EXT}`, { nodir: true, cwd: e2eRoot }).sort();
130-
const allInitializers = glob
131-
.sync(`initialize/**/*.${SRC_FILE_EXT}`, { nodir: true, cwd: e2eRoot })
132-
.sort();
123+
const allSetups = glob.sync(`setup/**/*.js`, { nodir: true, cwd: e2eRoot }).sort();
124+
const allInitializers = glob.sync(`initialize/**/*.js`, { nodir: true, cwd: e2eRoot }).sort();
125+
133126
const allTests = glob
134127
.sync(testGlob, { nodir: true, cwd: e2eRoot, ignore: argv.ignore })
135128
// Replace windows slashes.
136129
.map((name) => name.replace(/\\/g, '/'))
137130
.filter((name) => {
138-
if (name.endsWith(`/setup.${SRC_FILE_EXT}`)) {
131+
if (name.endsWith('/setup.js')) {
139132
return false;
140133
}
141134
if (!SRC_FILE_EXT_RE.test(name)) {
@@ -212,21 +205,8 @@ setGlobalVariable('package-manager', argv.yarn ? 'yarn' : 'npm');
212205
//
213206
// Resolve from relative paths to absolute paths within the bazel runfiles tree
214207
// so subprocesses spawned in a different working directory can still find them.
215-
process.env.CHROME_BIN = IS_BAZEL
216-
? path.resolve(process.env.CHROME_BIN!)
217-
: require('puppeteer').executablePath();
218-
process.env.CHROMEDRIVER_BIN = IS_BAZEL
219-
? path.resolve(process.env.CHROMEDRIVER_BIN!)
220-
: (function () {
221-
const protractorPath = require.resolve('protractor');
222-
const webdriverUpdatePath = require.resolve('webdriver-manager/selenium/update-config.json', {
223-
paths: [protractorPath],
224-
});
225-
const webdriverUpdate = JSON.parse(readFileSync(webdriverUpdatePath).toString()) as {
226-
chrome: { last: string };
227-
};
228-
return webdriverUpdate.chrome.last;
229-
})();
208+
process.env.CHROME_BIN = path.resolve(process.env.CHROME_BIN!);
209+
process.env.CHROMEDRIVER_BIN = path.resolve(process.env.CHROMEDRIVER_BIN!);
230210

231211
Promise.all([findFreePort(), findFreePort(), findPackageTars()])
232212
.then(async ([httpPort, httpsPort, packageTars]) => {
@@ -299,7 +279,7 @@ async function runSteps(
299279
const name = relativeName.replace(SRC_FILE_EXT_RE, '');
300280
const start = Date.now();
301281

302-
printHeader(relativeName, stepIndex, steps.length, type);
282+
printHeader(name, stepIndex, steps.length, type);
303283

304284
// Run the test function with the current file on the logStack.
305285
logStack.push(lastLogger().createChild(absoluteName));

tests/legacy-cli/run_e2e.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)