Fix test.py and tests to use an explicit --packages flag.

BUG=https://github.com/dart-lang/sdk/issues/27412
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/2361813003 .
This commit is contained in:
William Hesse 2016-09-22 17:51:09 +02:00
parent 7a570f1b80
commit 92cd3e10f5
19 changed files with 72 additions and 33 deletions

View file

@ -636,6 +636,9 @@ class Server {
if (Platform.packageRoot != null) {
arguments.add('--package-root=${Platform.packageRoot}');
}
if (Platform.packageConfig != null) {
arguments.add('--packages=${Platform.packageConfig}');
}
if (checked) {
arguments.add('--checked');
}

View file

@ -156,9 +156,11 @@ ${generateGraphData()}
context = AnalysisEngine.instance.createAnalysisContext();
ContextBuilder builder = new ContextBuilder(resourceProvider, null, null);
if (Platform.packageRoot != null) {
builder.defaultPackagesDirectoryPath = Uri.parse(Platform.packageRoot).toFilePath();
builder.defaultPackagesDirectoryPath =
Uri.parse(Platform.packageRoot).toFilePath();
} else if (Platform.packageConfig != null) {
builder.defaultPackageFilePath = Platform.packageConfig;
builder.defaultPackageFilePath =
Uri.parse(Platform.packageConfig).toFilePath();
} else {
// Let the context builder use the default algorithm for package
// resolution.

View file

@ -5,9 +5,6 @@
[ $browser == false || $runtime == drt || $fast_startup]
*: SkipByDesign
[ $runtime == dartium || $runtime == chrome || $runtime == ff ]
vm_connect/element_test: Skip # Times out. Issue 27397
[ $runtime == dartium ]
isolate/*: Skip
allocation_profile: Skip

View file

@ -165,6 +165,9 @@ runner.Command makeCompilationCommand(String testName, FileUtils fileUtils) {
}
void main() {
// This script is in [sdk]/tests/standalone/io.
suite.TestUtils.setDartDirUri(Platform.script.resolve('../../..'));
var fs_noTestJs = new FileUtils(createJs: false,
createJsDeps: true,
createDart: true,

View file

@ -141,6 +141,8 @@ class EventListener extends progress.EventListener{
}
void main(List<String> arguments) {
// This script is in [sdk]/tests/standalone/io.
TestUtils.setDartDirUri(Platform.script.resolve('../../..'));
// Run the test_runner_test if there are no command-line options.
// Otherwise, run one of the component tests that always pass,
// fail, or timeout.

View file

@ -2,7 +2,6 @@
// 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.
// PackageRoot=none
// Packages=.packages
// We expect this to not cause any errors. An empty packages file is valid,

View file

@ -2,7 +2,6 @@
// 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.
// PackageRoot=none
// Packages=.packages
library empty_packages_file_option_test;

View file

@ -2,7 +2,6 @@
// 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.
// PackageRoot=none
// Packages=invalid_package_name.packages
library invalid_package_name_test;

View file

@ -2,7 +2,6 @@
// 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.
// PackageRoot=none
// Packages=invalid_utf8.packages
library invalid_utf8_test;

View file

@ -2,7 +2,6 @@
// 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.
// PackageRoot=none
// Packages=non_existent.packages
library non_existent_packages_file_test;

View file

@ -2,7 +2,6 @@
// 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.
// PackageRoot=none
// Packages=same_package_twice.packages
library same_package_twice_test;

View file

@ -2,7 +2,6 @@
// 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.
// PackageRoot=none
// Packages=empty_lines.packages
library empty_lines_test;

View file

@ -2,7 +2,6 @@
// 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.
// PackageRoot=none
// Packages=empty_package_dir.packages
// In this test, we give a packages file that associates the package 'foo' with

View file

@ -2,7 +2,6 @@
// 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.
// PackageRoot=none
// Packages=mixed_line_ends.packages
library mixed_line_ends_test;

View file

@ -2,7 +2,6 @@
// 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.
// PackageRoot=none
// Packages=sub/.packages
library packages_option_only_noimports_test;

View file

@ -2,7 +2,6 @@
// 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.
// PackageRoot=none
// Packages=sub/.packages
library packages_option_only_test;

View file

@ -56,7 +56,7 @@ Future _deleteTemporaryDartDirectories() {
}
void main(List<String> arguments) {
// This script is in [dart]/tools.
// This script is in [sdk]/tools.
TestUtils.setDartDirUri(Platform.script.resolve('..'));
_deleteTemporaryDartDirectories().then((_) {
var optionsParser = new TestOptionsParser();

View file

@ -808,6 +808,40 @@ Note: currently only implemented for dart2js.''',
configuration['selectors'] = selectorMap;
}
// Put observatory_ui in a configuration with its own packages override.
// Only one value in the configuration map is mutable:
selectors = configuration['selectors'];
if (selectors.containsKey('observatory_ui')) {
if (selectors.length == 1) {
configuration['packages'] = TestUtils.dartDirUri
.resolve('runtime/observatory/.packages').toFilePath();
} else {
// Make a new configuration whose selectors map only contains
// observatory_ui, and remove the key from the original selectors.
// The only mutable value in the map is the selectors, so a
// shallow copy is safe.
var observatoryConfiguration = new Map.from(configuration);
observatoryConfiguration['selectors'] =
{'observatory_ui': selectors['observatory_ui']};
selectors.remove('observatory_ui');
// Set the packages flag.
observatoryConfiguration['packages'] = TestUtils.dartDirUri
.resolve('runtime/observatory/.packages').toFilePath();
// Return the expansions of both configurations. Neither will reach
// this line in the recursive call to _expandConfigurations.
return _expandConfigurations(configuration)
..addAll(_expandConfigurations(observatoryConfiguration));
}
}
// Set the default package spec explicitly.
if (configuration['package_root'] == null &&
configuration['packages'] == null) {
configuration['packages'] =
TestUtils.dartDirUri.resolve('.packages').toFilePath();
}
// Expand the architectures.
if (configuration['arch'].contains(',')) {
return _expandHelper('arch', configuration);

View file

@ -970,15 +970,17 @@ class StandardTestSuite extends TestSuite {
}
}
}
if (configuration['package_root'] != null) {
packageRoot = new Path(configuration['package_root']);
optionsFromFile['packageRoot'] = packageRoot.toNativePath();
if (optionsFromFile['packageRoot'] == null &&
optionsFromFile['packages'] == null) {
if (configuration['package_root'] != null) {
packageRoot = new Path(configuration['package_root']);
optionsFromFile['packageRoot'] = packageRoot.toNativePath();
}
if (configuration['packages'] != null) {
Path packages = new Path(configuration['packages']);
optionsFromFile['packages'] = packages.toNativePath();
}
}
if (configuration['packages'] != null) {
Path packages = new Path(configuration['packages']);
optionsFromFile['packages'] = packages.toNativePath();
}
if (new CompilerConfiguration(configuration).hasCompiler &&
expectCompileError(info)) {
// If a compile-time error is expected, and we're testing a
@ -1585,9 +1587,12 @@ class StandardTestSuite extends TestSuite {
String packagesArgument(String packageRootFromFile,
String packagesFromFile) {
if (packagesFromFile != null) {
if (packageRootFromFile == 'none' ||
packagesFromFile == 'none') {
return null;
} else if (packagesFromFile != null) {
return '--packages=$packagesFromFile';
} else if (packageRootFromFile != null && packageRootFromFile != 'none') {
} else if (packageRootFromFile != null) {
return '--package-root=$packageRootFromFile';
} else {
return null;
@ -1712,26 +1717,30 @@ class StandardTestSuite extends TestSuite {
matches = packageRootRegExp.allMatches(contents);
for (var match in matches) {
if (packageRoot != null) {
if (packageRoot != null || packages != null) {
throw new Exception(
'More than one "// PackageRoot=" line in test $filePath');
'More than one "// Package... line in test $filePath');
}
packageRoot = match[1];
if (packageRoot != 'none') {
// PackageRoot=none means that no package-root option should be given.
// PackageRoot=none means that no packages or package-root option
// should be given. Any other value overrides package-root and
// removes any packages option. Don't use with // Packages=.
packageRoot = '${filePath.directoryPath.join(new Path(packageRoot))}';
}
}
matches = packagesRegExp.allMatches(contents);
for (var match in matches) {
if (packages != null) {
if (packages != null || packageRoot != null) {
throw new Exception(
'More than one "// Packages=" line in test $filePath');
'More than one "// Package..." line in test $filePath');
}
packages = match[1];
if (packages != 'none') {
// Packages=none means that no packages option should be given.
// Packages=none means that no packages or package-root option
// should be given. Any other value overrides packages and removes
// any package-root option. Don't use with // PackageRoot=.
packages = '${filePath.directoryPath.join(new Path(packages))}';
}
}