mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-16 18:43:42 +08:00
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`
This commit is contained in:
parent
abcea344c3
commit
f30a69f260
@ -444,7 +444,7 @@ workflows:
|
||||
|
||||
# Publish jobs
|
||||
- snapshot_publish:
|
||||
# <<: *only_release_branches
|
||||
<<: *only_release_branches
|
||||
requires:
|
||||
- setup
|
||||
- e2e-cli
|
||||
|
@ -4,7 +4,9 @@ load(":e2e.bzl", "e2e_suites")
|
||||
ts_library(
|
||||
name = "runner",
|
||||
testonly = True,
|
||||
srcs = glob(["**/*.ts"]),
|
||||
srcs = [
|
||||
"e2e_runner.ts",
|
||||
],
|
||||
data = [
|
||||
"verdaccio.yaml",
|
||||
"verdaccio_auth.yaml",
|
||||
|
@ -1,10 +1,9 @@
|
||||
import { join } from 'path';
|
||||
import yargsParser from 'yargs-parser';
|
||||
import { IS_BAZEL } from '../utils/bazel';
|
||||
import { getGlobalVariable } from '../utils/env';
|
||||
import { expectFileToExist } from '../utils/fs';
|
||||
import { gitClean } from '../utils/git';
|
||||
import { installPackage, setRegistry as setNPMConfigRegistry } from '../utils/packages';
|
||||
import { setRegistry as setNPMConfigRegistry } from '../utils/packages';
|
||||
import { ng } from '../utils/process';
|
||||
import { prepareProjectForE2e, updateJsonFile } from '../utils/project';
|
||||
|
||||
@ -22,16 +21,6 @@ export default async function () {
|
||||
// Ensure local test registry is used when outside a project
|
||||
await setNPMConfigRegistry(true);
|
||||
|
||||
// Install puppeteer in the parent directory for use by the CLI within any test project.
|
||||
// Align the version with the primary project package.json.
|
||||
// Bazel has own browser toolchains
|
||||
// TODO(bazel): remove non-bazel
|
||||
if (!IS_BAZEL) {
|
||||
const puppeteerVersion =
|
||||
require('../../../../package.json').devDependencies.puppeteer.replace(/^[\^~]/, '');
|
||||
await installPackage(`puppeteer@${puppeteerVersion}`);
|
||||
}
|
||||
|
||||
await ng('new', 'test-project', '--skip-install');
|
||||
await expectFileToExist(join(process.cwd(), 'test-project'));
|
||||
process.chdir('./test-project');
|
||||
|
@ -1,10 +1,9 @@
|
||||
import { join } from 'path';
|
||||
import { IS_BAZEL } from '../../utils/bazel';
|
||||
import { execWithEnv } from '../../utils/process';
|
||||
|
||||
export default async function () {
|
||||
// TODO(bazel): fails with bazel on windows
|
||||
if (IS_BAZEL && process.platform.startsWith('win')) {
|
||||
if (process.platform.startsWith('win')) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1,3 +0,0 @@
|
||||
// TODO(bazel): remove this along with any non-bazel specific logic using it.
|
||||
|
||||
export const IS_BAZEL = !!process.env.BAZEL_TARGET;
|
@ -7,7 +7,6 @@ import { getGlobalVariable, getGlobalVariablesEnv } from './env';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
import treeKill from 'tree-kill';
|
||||
import { delimiter, join, resolve } from 'path';
|
||||
import { IS_BAZEL } from './bazel';
|
||||
|
||||
interface ExecOptions {
|
||||
silent?: boolean;
|
||||
@ -420,11 +419,7 @@ export async function launchTestProcess(entry: string, ...args: any[]): Promise<
|
||||
.filter((p) => p.startsWith(tempRoot) || p.startsWith(TEMP) || !p.includes('angular-cli'))
|
||||
.join(delimiter);
|
||||
|
||||
const testProcessArgs = [
|
||||
resolve(__dirname, IS_BAZEL ? 'test_process' : 'run_test_process'),
|
||||
entry,
|
||||
...args,
|
||||
];
|
||||
const testProcessArgs = [resolve(__dirname, 'test_process'), entry, ...args];
|
||||
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
spawn(process.execPath, testProcessArgs, {
|
||||
|
@ -2,13 +2,12 @@ import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import { prerelease, SemVer } from 'semver';
|
||||
import yargsParser from 'yargs-parser';
|
||||
import { IS_BAZEL } from './bazel';
|
||||
import { getGlobalVariable } from './env';
|
||||
import { readFile, replaceInFile, writeFile } from './fs';
|
||||
import { gitCommit } from './git';
|
||||
import { findFreePort } from './network';
|
||||
import { installWorkspacePackages, PkgInfo } from './packages';
|
||||
import { exec, execAndWaitForOutputToMatch, git, ng } from './process';
|
||||
import { execAndWaitForOutputToMatch, git, ng } from './process';
|
||||
|
||||
export function updateJsonFile(filePath: string, fn: (json: any) => any | void) {
|
||||
return readFile(filePath).then((tsConfigJson) => {
|
||||
@ -51,43 +50,6 @@ export async function prepareProjectForE2e(name: string) {
|
||||
await installWorkspacePackages();
|
||||
await ng('generate', 'e2e', '--related-app-name', name);
|
||||
|
||||
// bazel will use its own sandboxed browser + webdriver
|
||||
// TODO(bazel): remove non-bazel
|
||||
if (!IS_BAZEL) {
|
||||
const protractorPath = require.resolve('protractor');
|
||||
const webdriverUpdatePath = require.resolve('webdriver-manager/selenium/update-config.json', {
|
||||
paths: [protractorPath],
|
||||
});
|
||||
const webdriverUpdate = JSON.parse(await readFile(webdriverUpdatePath)) as {
|
||||
chrome: { last: string };
|
||||
};
|
||||
|
||||
const chromeDriverVersion = webdriverUpdate.chrome.last.match(/chromedriver_([\d|\.]+)/)?.[1];
|
||||
if (!chromeDriverVersion) {
|
||||
throw new Error('Could not extract chrome webdriver version.');
|
||||
}
|
||||
|
||||
// Initialize selenium webdriver.
|
||||
// Often fails the first time so attempt twice if necessary.
|
||||
const runWebdriverUpdate = () =>
|
||||
exec(
|
||||
process.execPath,
|
||||
'node_modules/protractor/bin/webdriver-manager',
|
||||
'update',
|
||||
'--standalone',
|
||||
'false',
|
||||
'--gecko',
|
||||
'false',
|
||||
'--versions.chrome',
|
||||
chromeDriverVersion,
|
||||
);
|
||||
try {
|
||||
await runWebdriverUpdate();
|
||||
} catch {
|
||||
await runWebdriverUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
await useCIChrome(name, 'e2e');
|
||||
await useCIChrome(name, '');
|
||||
await useCIDefaults(name);
|
||||
|
@ -1,3 +0,0 @@
|
||||
'use strict';
|
||||
require('../../../../lib/bootstrap-local');
|
||||
require('./test_process');
|
@ -1,4 +1,3 @@
|
||||
import { logging } from '../../packages/angular_devkit/core/src';
|
||||
import { createConsoleLogger } from '../../packages/angular_devkit/core/node';
|
||||
import * as colors from 'ansi-colors';
|
||||
import glob from 'glob';
|
||||
@ -9,10 +8,9 @@ import { gitClean } from './e2e/utils/git';
|
||||
import { createNpmRegistry } from './e2e/utils/registry';
|
||||
import { launchTestProcess } from './e2e/utils/process';
|
||||
import { delimiter, dirname, join } from 'path';
|
||||
import { IS_BAZEL } from './e2e/utils/bazel';
|
||||
import { findFreePort } from './e2e/utils/network';
|
||||
import { extractFile } from './e2e/utils/tar';
|
||||
import { readFileSync, realpathSync } from 'fs';
|
||||
import { realpathSync } from 'fs';
|
||||
import { PkgInfo } from './e2e/utils/packages';
|
||||
|
||||
Error.stackTraceLimit = Infinity;
|
||||
@ -57,12 +55,11 @@ const argv = yargsParser(process.argv.slice(2), {
|
||||
number: ['nb-shards', 'shard'],
|
||||
array: ['package'],
|
||||
configuration: {
|
||||
'dot-notation': false,
|
||||
'camel-case-expansion': false,
|
||||
'dot-notation': false,
|
||||
},
|
||||
default: {
|
||||
'package': ['./dist/_*.tgz'],
|
||||
|
||||
'debug': !!process.env.BUILD_WORKSPACE_DIRECTORY,
|
||||
'glob': process.env.TESTBRIDGE_TEST_ONLY,
|
||||
'nb-shards':
|
||||
@ -119,23 +116,19 @@ function lastLogger() {
|
||||
}
|
||||
|
||||
// Under bazel the compiled file (.js) and types (.d.ts) are available.
|
||||
// Outside bazel the source .ts files are available.
|
||||
const SRC_FILE_EXT = IS_BAZEL ? 'js' : 'ts';
|
||||
const SRC_FILE_EXT_RE = new RegExp(`\.${SRC_FILE_EXT}$`);
|
||||
|
||||
const testGlob = argv.glob || `tests/**/*.${SRC_FILE_EXT}`;
|
||||
const SRC_FILE_EXT_RE = /\.js$/;
|
||||
const testGlob = argv.glob?.replace(/\.ts$/, '.js') || `tests/**/*.js`;
|
||||
|
||||
const e2eRoot = path.join(__dirname, 'e2e');
|
||||
const allSetups = glob.sync(`setup/**/*.${SRC_FILE_EXT}`, { nodir: true, cwd: e2eRoot }).sort();
|
||||
const allInitializers = glob
|
||||
.sync(`initialize/**/*.${SRC_FILE_EXT}`, { nodir: true, cwd: e2eRoot })
|
||||
.sort();
|
||||
const allSetups = glob.sync(`setup/**/*.js`, { nodir: true, cwd: e2eRoot }).sort();
|
||||
const allInitializers = glob.sync(`initialize/**/*.js`, { nodir: true, cwd: e2eRoot }).sort();
|
||||
|
||||
const allTests = glob
|
||||
.sync(testGlob, { nodir: true, cwd: e2eRoot, ignore: argv.ignore })
|
||||
// Replace windows slashes.
|
||||
.map((name) => name.replace(/\\/g, '/'))
|
||||
.filter((name) => {
|
||||
if (name.endsWith(`/setup.${SRC_FILE_EXT}`)) {
|
||||
if (name.endsWith('/setup.js')) {
|
||||
return false;
|
||||
}
|
||||
if (!SRC_FILE_EXT_RE.test(name)) {
|
||||
@ -212,21 +205,8 @@ setGlobalVariable('package-manager', argv.yarn ? 'yarn' : 'npm');
|
||||
//
|
||||
// Resolve from relative paths to absolute paths within the bazel runfiles tree
|
||||
// so subprocesses spawned in a different working directory can still find them.
|
||||
process.env.CHROME_BIN = IS_BAZEL
|
||||
? path.resolve(process.env.CHROME_BIN!)
|
||||
: require('puppeteer').executablePath();
|
||||
process.env.CHROMEDRIVER_BIN = IS_BAZEL
|
||||
? path.resolve(process.env.CHROMEDRIVER_BIN!)
|
||||
: (function () {
|
||||
const protractorPath = require.resolve('protractor');
|
||||
const webdriverUpdatePath = require.resolve('webdriver-manager/selenium/update-config.json', {
|
||||
paths: [protractorPath],
|
||||
});
|
||||
const webdriverUpdate = JSON.parse(readFileSync(webdriverUpdatePath).toString()) as {
|
||||
chrome: { last: string };
|
||||
};
|
||||
return webdriverUpdate.chrome.last;
|
||||
})();
|
||||
process.env.CHROME_BIN = path.resolve(process.env.CHROME_BIN!);
|
||||
process.env.CHROMEDRIVER_BIN = path.resolve(process.env.CHROMEDRIVER_BIN!);
|
||||
|
||||
Promise.all([findFreePort(), findFreePort(), findPackageTars()])
|
||||
.then(async ([httpPort, httpsPort, packageTars]) => {
|
||||
@ -299,7 +279,7 @@ async function runSteps(
|
||||
const name = relativeName.replace(SRC_FILE_EXT_RE, '');
|
||||
const start = Date.now();
|
||||
|
||||
printHeader(relativeName, stepIndex, steps.length, type);
|
||||
printHeader(name, stepIndex, steps.length, type);
|
||||
|
||||
// Run the test function with the current file on the logStack.
|
||||
logStack.push(lastLogger().createChild(absoluteName));
|
||||
|
@ -1,3 +0,0 @@
|
||||
'use strict';
|
||||
require('../../lib/bootstrap-local');
|
||||
require('./e2e_runner.ts');
|
Loading…
x
Reference in New Issue
Block a user