[Test.dart] Use Compiler, Runtime, etc. classes from pkg:smith.

Change-Id: I1251c94e87fe6953f7604b5ef8f6ae5c49ab36d3
Reviewed-on: https://dart-review.googlesource.com/67522
Commit-Queue: William Hesse <whesse@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
This commit is contained in:
William Hesse 2018-08-01 09:45:17 +00:00 committed by commit-bot@chromium.org
parent 55880dfeed
commit cf77a3b00f
9 changed files with 39 additions and 523 deletions

View file

@ -540,6 +540,7 @@ class Compiler extends NamedEnum {
Runtime.ie9,
Runtime.ie10,
Runtime.ie11,
Runtime.edge,
Runtime.chromeOnAndroid,
];
@ -557,6 +558,7 @@ class Compiler extends NamedEnum {
case Compiler.appJit:
case Compiler.appJitk:
case Compiler.dartk:
case Compiler.dartkb:
return const [Runtime.vm, Runtime.selfCheck];
case Compiler.precompiler:
case Compiler.dartkp:
@ -586,6 +588,7 @@ class Compiler extends NamedEnum {
case Compiler.appJit:
case Compiler.appJitk:
case Compiler.dartk:
case Compiler.dartkb:
return Runtime.vm;
case Compiler.precompiler:
case Compiler.dartkp:
@ -650,6 +653,7 @@ class Runtime extends NamedEnum {
static const ie9 = const Runtime._('ie9');
static const ie10 = const Runtime._('ie10');
static const ie11 = const Runtime._('ie11');
static const edge = const Runtime._('edge');
static const chromeOnAndroid = const Runtime._('chromeOnAndroid');
static const selfCheck = const Runtime._('self_check');
static const none = const Runtime._('none');
@ -668,6 +672,7 @@ class Runtime extends NamedEnum {
ie9,
ie10,
ie11,
edge,
chromeOnAndroid,
selfCheck,
none
@ -686,6 +691,7 @@ class Runtime extends NamedEnum {
ie9,
ie10,
ie11,
edge,
safari,
chrome,
firefox,
@ -721,6 +727,7 @@ class Runtime extends NamedEnum {
case ie9:
case ie10:
case ie11:
case edge:
case chromeOnAndroid:
return Compiler.dart2js;

View file

@ -88,31 +88,6 @@
"xcodebuild/ReleaseX64/dart2js_platform.dill",
"xcodebuild/ReleaseX64/dart2js_platform_strong.dill"
],
"vm_debug": [
"out/DebugIA32/",
"out/DebugX64/",
"xcodebuild/DebugIA32/",
"xcodebuild/DebugX64/",
"samples/",
"samples-dev/",
"tools/",
"third_party/pkg/",
"third_party/pkg_tested/",
"third_party/d8/",
"third_party/firefox_jsshell/",
"third_party/observatory_pub_packages/packages/",
"tests/",
"pkg/async_helper/",
"pkg/expect/",
"pkg/js/",
"pkg/meta/",
"pkg/pkg.status",
"pkg/status_file/",
"pkg/vm/",
"runtime/",
"sdk/",
".packages"
],
"vm-kernel": [
"out/DebugIA32/",
"out/DebugSIMARM/",
@ -159,6 +134,7 @@
"pkg/kernel/",
"pkg/meta/",
"pkg/pkg.status",
"pkg/smith/",
"pkg/status_file/",
"pkg/vm/",
"runtime/",

View file

@ -6,6 +6,9 @@ import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'package:smith/smith.dart';
export 'package:smith/smith.dart';
import 'compiler_configuration.dart';
import 'http_server.dart';
import 'path.dart';
@ -287,9 +290,6 @@ class TestConfiguration {
case Runtime.chrome:
location = chromePath;
break;
case Runtime.drt:
location = drtPath;
break;
case Runtime.firefox:
location = firefoxPath;
break;
@ -305,28 +305,28 @@ class TestConfiguration {
const locations = const {
Runtime.firefox: const {
System.windows: 'C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe',
System.win: 'C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe',
System.linux: 'firefox',
System.macos: '/Applications/Firefox.app/Contents/MacOS/firefox'
System.mac: '/Applications/Firefox.app/Contents/MacOS/firefox'
},
Runtime.chrome: const {
System.windows:
System.win:
'C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe',
System.macos:
System.mac:
'/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
System.linux: 'google-chrome'
},
Runtime.safari: const {
System.macos: '/Applications/Safari.app/Contents/MacOS/Safari'
System.mac: '/Applications/Safari.app/Contents/MacOS/Safari'
},
Runtime.ie9: const {
System.windows: 'C:\\Program Files\\Internet Explorer\\iexplore.exe'
System.win: 'C:\\Program Files\\Internet Explorer\\iexplore.exe'
},
Runtime.ie10: const {
System.windows: 'C:\\Program Files\\Internet Explorer\\iexplore.exe'
System.win: 'C:\\Program Files\\Internet Explorer\\iexplore.exe'
},
Runtime.ie11: const {
System.windows: 'C:\\Program Files\\Internet Explorer\\iexplore.exe'
System.win: 'C:\\Program Files\\Internet Explorer\\iexplore.exe'
}
};
@ -489,228 +489,6 @@ class TestConfiguration {
}
}
class Architecture {
static const ia32 = const Architecture._('ia32');
static const x64 = const Architecture._('x64');
static const arm = const Architecture._('arm');
static const armv6 = const Architecture._('armv6');
static const armv5te = const Architecture._('armv5te');
static const arm64 = const Architecture._('arm64');
static const simarm = const Architecture._('simarm');
static const simarmv6 = const Architecture._('simarmv6');
static const simarmv5te = const Architecture._('simarmv5te');
static const simarm64 = const Architecture._('simarm64');
static const simdbc = const Architecture._('simdbc');
static const simdbc64 = const Architecture._('simdbc64');
static final List<String> names = _all.keys.toList();
static final _all = new Map<String, Architecture>.fromIterable([
ia32,
x64,
arm,
armv6,
armv5te,
arm64,
simarm,
simarmv6,
simarmv5te,
simarm64,
simdbc,
simdbc64,
], key: (architecture) => (architecture as Architecture).name);
static Architecture find(String name) {
var architecture = _all[name];
if (architecture != null) return architecture;
throw new ArgumentError('Unknown architecture "$name".');
}
final String name;
const Architecture._(this.name);
String toString() => "Architecture($name)";
}
class Compiler {
static const none = const Compiler._('none');
static const precompiler = const Compiler._('precompiler');
static const dart2js = const Compiler._('dart2js');
static const dart2analyzer = const Compiler._('dart2analyzer');
static const dartdevc = const Compiler._('dartdevc');
static const dartdevk = const Compiler._('dartdevk');
static const appJit = const Compiler._('app_jit');
static const appJitk = const Compiler._('app_jitk');
static const dartk = const Compiler._('dartk');
static const dartkb = const Compiler._('dartkb');
static const dartkp = const Compiler._('dartkp');
static const specParser = const Compiler._('spec_parser');
static const fasta = const Compiler._('fasta');
static final List<String> names = _all.keys.toList();
static final _all = new Map<String, Compiler>.fromIterable([
none,
precompiler,
dart2js,
dart2analyzer,
dartdevc,
dartdevk,
appJit,
appJitk,
dartk,
dartkb,
dartkp,
specParser,
fasta,
], key: (compiler) => (compiler as Compiler).name);
static Compiler find(String name) {
var compiler = _all[name];
if (compiler != null) return compiler;
throw new ArgumentError('Unknown compiler "$name".');
}
final String name;
const Compiler._(this.name);
/// Gets the runtimes this compiler can target.
List<Runtime> get supportedRuntimes {
switch (this) {
case Compiler.dart2js:
// Note: by adding 'none' as a configuration, if the user
// runs test.py -c dart2js -r drt,none the dart2js_none and
// dart2js_drt will be duplicating work. If later we don't need 'none'
// with dart2js, we should remove it from here.
return const [
Runtime.d8,
Runtime.jsshell,
Runtime.drt,
Runtime.none,
Runtime.firefox,
Runtime.chrome,
Runtime.safari,
Runtime.ie9,
Runtime.ie10,
Runtime.ie11,
Runtime.opera,
Runtime.chromeOnAndroid,
];
case Compiler.dartdevc:
case Compiler.dartdevk:
// TODO(rnystrom): Expand to support other JS execution environments
// (other browsers, d8) when tested and working.
return const [
Runtime.none,
Runtime.drt,
Runtime.chrome,
];
case Compiler.dart2analyzer:
return const [Runtime.none];
case Compiler.appJit:
case Compiler.appJitk:
case Compiler.dartk:
return const [Runtime.vm, Runtime.selfCheck];
case Compiler.dartkb:
return const [Runtime.vm, Runtime.selfCheck];
case Compiler.precompiler:
case Compiler.dartkp:
return const [Runtime.dartPrecompiled];
case Compiler.specParser:
return const [Runtime.none];
case Compiler.fasta:
return const [Runtime.none];
case Compiler.none:
return const [
Runtime.vm,
Runtime.flutter,
Runtime.drt,
Runtime.contentShellOnAndroid
];
}
throw "unreachable";
}
/// The preferred runtime to use with this compiler if no other runtime is
/// specified.
Runtime get defaultRuntime {
switch (this) {
case Compiler.dart2js:
return Runtime.d8;
case Compiler.dartdevc:
case Compiler.dartdevk:
return Runtime.chrome;
case Compiler.dart2analyzer:
return Runtime.none;
case Compiler.appJit:
case Compiler.appJitk:
case Compiler.dartk:
case Compiler.dartkb:
return Runtime.vm;
case Compiler.precompiler:
case Compiler.dartkp:
return Runtime.dartPrecompiled;
case Compiler.specParser:
case Compiler.fasta:
return Runtime.none;
case Compiler.none:
return Runtime.vm;
}
throw "unreachable";
}
Mode get defaultMode {
switch (this) {
case Compiler.dart2analyzer:
case Compiler.dart2js:
case Compiler.dartdevc:
case Compiler.dartdevk:
case Compiler.fasta:
return Mode.release;
default:
return Mode.debug;
}
}
String toString() => "Compiler($name)";
}
class Mode {
static const debug = const Mode._('debug');
static const product = const Mode._('product');
static const release = const Mode._('release');
static final List<String> names = _all.keys.toList();
static final _all = new Map<String, Mode>.fromIterable(
[debug, product, release],
key: (mode) => (mode as Mode).name);
static Mode find(String name) {
var mode = _all[name];
if (mode != null) return mode;
throw new ArgumentError('Unknown mode "$name".');
}
final String name;
const Mode._(this.name);
bool get isDebug => this == debug;
String toString() => "Mode($name)";
}
class Progress {
static const compact = const Progress._('compact');
static const color = const Progress._('color');
@ -740,163 +518,3 @@ class Progress {
String toString() => "Progress($name)";
}
class Runtime {
static const vm = const Runtime._('vm');
static const flutter = const Runtime._('flutter');
static const dartPrecompiled = const Runtime._('dart_precompiled');
static const d8 = const Runtime._('d8');
static const jsshell = const Runtime._('jsshell');
static const drt = const Runtime._('drt');
static const firefox = const Runtime._('firefox');
static const chrome = const Runtime._('chrome');
static const safari = const Runtime._('safari');
static const ie9 = const Runtime._('ie9');
static const ie10 = const Runtime._('ie10');
static const ie11 = const Runtime._('ie11');
static const opera = const Runtime._('opera');
static const chromeOnAndroid = const Runtime._('chromeOnAndroid');
static const contentShellOnAndroid = const Runtime._('ContentShellOnAndroid');
static const selfCheck = const Runtime._('self_check');
static const none = const Runtime._('none');
static final List<String> names = _all.keys.toList()..add("ff");
static final _all = new Map<String, Runtime>.fromIterable([
vm,
flutter,
dartPrecompiled,
d8,
jsshell,
drt,
firefox,
chrome,
safari,
ie9,
ie10,
ie11,
opera,
chromeOnAndroid,
contentShellOnAndroid,
selfCheck,
none
], key: (runtime) => (runtime as Runtime).name);
static Runtime find(String name) {
// Allow "ff" as a synonym for Firefox.
if (name == "ff") return firefox;
var runtime = _all[name];
if (runtime != null) return runtime;
throw new ArgumentError('Unknown runtime "$name".');
}
final String name;
const Runtime._(this.name);
bool get isBrowser => const [
drt,
ie9,
ie10,
ie11,
safari,
opera,
chrome,
firefox,
chromeOnAndroid,
contentShellOnAndroid
].contains(this);
bool get isIE => name.startsWith("ie");
bool get isSafari => name.startsWith("safari");
/// Whether this runtime is a command-line JavaScript environment.
bool get isJSCommandLine => const [d8, jsshell].contains(this);
/// If the runtime doesn't support `Window.open`, we use iframes instead.
bool get requiresIFrame => !const [ie11, ie10].contains(this);
/// The preferred compiler to use with this runtime if no other compiler is
/// specified.
Compiler get defaultCompiler {
switch (this) {
case vm:
case flutter:
case drt:
return Compiler.none;
case dartPrecompiled:
return Compiler.precompiler;
case d8:
case jsshell:
case firefox:
case chrome:
case safari:
case ie9:
case ie10:
case ie11:
case opera:
case chromeOnAndroid:
case contentShellOnAndroid:
return Compiler.dart2js;
case selfCheck:
return Compiler.dartk;
case none:
// If we aren't running it, we probably just want to analyze it.
return Compiler.dart2analyzer;
}
throw "unreachable";
}
String toString() => "Runtime($name)";
}
class System {
static const android = const System._('android');
static const fuchsia = const System._('fuchsia');
static const linux = const System._('linux');
static const macos = const System._('macos');
static const windows = const System._('windows');
static final List<String> names = _all.keys.toList();
static final _all = new Map<String, System>.fromIterable(
[android, fuchsia, linux, macos, windows],
key: (system) => (system as System).name);
static System find(String name) {
var system = _all[name];
if (system != null) return system;
throw new ArgumentError('Unknown operating system "$name".');
}
final String name;
const System._(this.name);
/// The root directory name for build outputs on this system.
String get outputDirectory {
switch (this) {
case android:
case fuchsia:
case linux:
case windows:
return 'out/';
case macos:
return 'xcodebuild/';
}
throw "unreachable";
}
String toString() => "System($name)";
}

View file

@ -36,10 +36,10 @@ final _variables = {
"mode": new _Variable((c) => c.mode.name, Mode.names),
"no_preview_dart_2": new _Variable.bool((c) => c.noPreviewDart2),
"preview_dart_2": new _Variable.bool((c) => !c.noPreviewDart2),
"runtime": new _Variable(_runtimeName, Runtime.names),
"runtime": new _Variable(_runtimeName, _runtimeNames),
"spec_parser": new _Variable.bool((c) => c.compiler == Compiler.specParser),
"strong": new _Variable.bool((c) => !c.noPreviewDart2),
"system": new _Variable((c) => c.system.name, System.names),
"system": new _Variable(_systemName, _systemNames),
"use_sdk": new _Variable.bool((c) => c.useSdk)
};
@ -53,6 +53,20 @@ String _runtimeName(TestConfiguration configuration) {
return configuration.runtime.name;
}
List<String> _runtimeNames = ['ff', 'drt']..addAll(Runtime.names);
/// Gets the name of the runtime as it appears in status files.
String _systemName(TestConfiguration configuration) {
// Because we are getting rid of status files, we don't want to change all
// of them to say "win" instead of "windows" and "mac" instead of "macos"
if (configuration.system == System.win) return 'windows';
if (configuration.system == System.mac) return 'macos';
return configuration.system.name;
}
List<String> _systemNames = ['windows', 'macos']..addAll(System.names);
/// Defines the variables that are available for use inside a status file
/// section header.
///

View file

@ -7,7 +7,6 @@ import 'dart:io';
import 'configuration.dart';
import 'path.dart';
import 'repository.dart';
import 'runtime_updater.dart';
import 'utils.dart';
const _defaultTestSelectors = const [
@ -617,11 +616,6 @@ compiler.''',
// Expand runtimes.
for (var runtime in runtimes) {
// Start installing the runtime if needed.
if (runtime == Runtime.drt &&
!(data["list"] as bool) &&
!(data["list_status_files"] as bool)) {
updateContentShell(data["drt"] as String);
}
// Expand architectures.
var architectures = data["arch"] as String;

View file

@ -22,14 +22,12 @@ abstract class RuntimeConfiguration {
static RuntimeConfiguration _makeInstance(TestConfiguration configuration) {
switch (configuration.runtime) {
case Runtime.contentShellOnAndroid:
case Runtime.chrome:
case Runtime.chromeOnAndroid:
case Runtime.firefox:
case Runtime.ie11:
case Runtime.ie10:
case Runtime.ie9:
case Runtime.opera:
case Runtime.safari:
// TODO(ahe): Replace this with one or more browser runtimes.
return new DummyRuntimeConfiguration();
@ -59,9 +57,6 @@ abstract class RuntimeConfiguration {
}
break;
case Runtime.drt:
return new DrtRuntimeConfiguration();
case Runtime.selfCheck:
return new SelfCheckRuntimeConfiguration();
}

View file

@ -1,52 +0,0 @@
// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'dart:async';
import 'dart:io';
import 'repository.dart';
Future _contentShellFuture;
/// Runs "tools/get_archive.py" to download and install Content Shell.
Future updateContentShell(String drtPath) {
if (_contentShellFuture == null) {
_contentShellFuture =
new _RuntimeUpdater('Content Shell', 'tools/get_archive.py', 'drt')
.update();
}
return _contentShellFuture;
}
class _RuntimeUpdater {
String _name;
String _script;
String _option;
_RuntimeUpdater(this._name, this._script, [this._option]);
Future update() async {
try {
print('Updating $_name...');
var arguments = [Repository.uri.resolve(_script).toFilePath()];
if (_option != null) arguments.add(_option);
var result = await Process.run('python', arguments);
if (result.exitCode == 0) {
print('Updated $_name.');
} else {
print('Failed to update $_name (exit code ${result.exitCode}):');
print(result.stdout);
print(result.stderr);
exit(1);
}
} catch (error) {
print("Error starting $_script process: $error");
exit(1);
}
}
}

View file

@ -145,12 +145,6 @@ Future testConfigurations(List<TestConfiguration> configurations) async {
// Issue: https://github.com/dart-lang/sdk/issues/23891
// This change does not fix the problem.
maxBrowserProcesses = math.max(1, maxBrowserProcesses ~/ 2);
} else if (configuration.runtime != Runtime.drt) {
// Even on machines with more than 16 processors, don't open more
// than 15 browser instances, to avoid overloading the machine.
// This is especially important when running locally on powerful
// desktops.
maxBrowserProcesses = math.min(maxBrowserProcesses, 15);
}
// If we specifically pass in a suite only run that.

View file

@ -27,7 +27,6 @@ import 'http_server.dart';
import 'multitest.dart';
import 'path.dart';
import 'repository.dart';
import 'runtime_updater.dart';
import 'summary_report.dart';
import 'test_configurations.dart';
import 'test_runner.dart';
@ -656,10 +655,6 @@ class StandardTestSuite extends TestSuite {
Future forEachTest(
Function onTest, Map<String, List<TestInformation>> testCache,
[VoidFunction onDone]) async {
if (configuration.runtime == Runtime.drt && !configuration.listTests) {
await updateContentShell(configuration.drtPath);
}
doTest = onTest;
testExpectations = readExpectations();
@ -1127,27 +1122,8 @@ class StandardTestSuite extends TestSuite {
var htmlPathSubtest = _createUrlPathFromFile(new Path(htmlPath));
var fullHtmlPath = _uriForBrowserTest(htmlPathSubtest, subtestName);
if (configuration.runtime == Runtime.drt) {
var dartFlags = <String>[];
var contentShellOptions = ['--no-timeout', '--run-layout-test'];
// Disable the GPU under Linux and Dartium. If the GPU is enabled,
// Chrome may send a termination signal to a test. The test will be
// terminated if a machine (bot) doesn't have a GPU or if a test is
// still running after a certain period of time.
if (configuration.system == System.linux &&
configuration.runtime == Runtime.drt) {
contentShellOptions.add('--disable-gpu');
// TODO(terry): Roll 50 need this in conjection with disable-gpu.
contentShellOptions.add('--disable-gpu-early-init');
}
commands.add(Command.contentShell(contentShellFilename, fullHtmlPath,
contentShellOptions, dartFlags, environmentOverrides));
} else {
commands.add(Command.browserTest(fullHtmlPath, configuration,
retry: !isNegative(info)));
}
commands.add(Command.browserTest(fullHtmlPath, configuration,
retry: !isNegative(info)));
var fullName = testName;
if (subtestName != null) fullName += "/$subtestName";
@ -1166,7 +1142,7 @@ class StandardTestSuite extends TestSuite {
}
// HTML tests work only with the browser controller.
if (!runtime.isBrowser || runtime == Runtime.drt) return;
if (!runtime.isBrowser) return;
var compileToJS = compiler == Compiler.dart2js;
@ -1614,13 +1590,7 @@ class StandardTestSuite extends TestSuite {
Compiler.appJit
];
const runtimes = const [
Runtime.none,
Runtime.dartPrecompiled,
Runtime.vm,
Runtime.drt,
Runtime.contentShellOnAndroid
];
const runtimes = const [Runtime.none, Runtime.dartPrecompiled, Runtime.vm];
var needsVmOptions = compilers.contains(configuration.compiler) &&
runtimes.contains(configuration.runtime);