Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * Classes and methods for enumerating and preparing tests. | 6 * Classes and methods for enumerating and preparing tests. |
| 7 * | 7 * |
| 8 * This library includes: | 8 * This library includes: |
| 9 * | 9 * |
| 10 * - Creating tests by listing all the Dart files in certain directories, | 10 * - Creating tests by listing all the Dart files in certain directories, |
| (...skipping 955 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 966 if (optionsFromFile['packageRoot'] == null || | 966 if (optionsFromFile['packageRoot'] == null || |
| 967 optionsFromFile['packageRoot'] == "") { | 967 optionsFromFile['packageRoot'] == "") { |
| 968 optionsFromFile['packageRoot'] = packageRoot.toNativePath(); | 968 optionsFromFile['packageRoot'] = packageRoot.toNativePath(); |
| 969 } | 969 } |
| 970 } | 970 } |
| 971 } | 971 } |
| 972 if (configuration['package_root'] != null) { | 972 if (configuration['package_root'] != null) { |
| 973 packageRoot = new Path(configuration['package_root']); | 973 packageRoot = new Path(configuration['package_root']); |
| 974 optionsFromFile['packageRoot'] = packageRoot.toNativePath(); | 974 optionsFromFile['packageRoot'] = packageRoot.toNativePath(); |
| 975 } | 975 } |
| 976 if (configuration['packages'] != null) { | |
| 977 Path packages = new Path(configuration['packages']); | |
| 978 optionsFromFile['packages'] = packages.toNativePath(); | |
| 979 } | |
| 976 | 980 |
| 977 if (new CompilerConfiguration(configuration).hasCompiler && | 981 if (new CompilerConfiguration(configuration).hasCompiler && |
| 978 expectCompileError(info)) { | 982 expectCompileError(info)) { |
| 979 // If a compile-time error is expected, and we're testing a | 983 // If a compile-time error is expected, and we're testing a |
| 980 // compiler, we never need to attempt to run the program (in a | 984 // compiler, we never need to attempt to run the program (in a |
| 981 // browser or otherwise). | 985 // browser or otherwise). |
| 982 enqueueStandardTest(baseCommands, info, testName, expectations); | 986 enqueueStandardTest(baseCommands, info, testName, expectations); |
| 983 } else if (TestUtils.isBrowserRuntime(configuration['runtime'])) { | 987 } else if (TestUtils.isBrowserRuntime(configuration['runtime'])) { |
| 984 if (info.optionsFromFile['isMultiHtmlTest']) { | 988 if (info.optionsFromFile['isMultiHtmlTest']) { |
| 985 // A browser multi-test has multiple expectations for one test file. | 989 // A browser multi-test has multiple expectations for one test file. |
| (...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1464 String dir, optionsFromFile) { | 1468 String dir, optionsFromFile) { |
| 1465 assert(compiler == 'dart2js'); | 1469 assert(compiler == 'dart2js'); |
| 1466 List<String> args; | 1470 List<String> args; |
| 1467 if (compilerPath.endsWith('.dart')) { | 1471 if (compilerPath.endsWith('.dart')) { |
| 1468 // Run the compiler script via the Dart VM. | 1472 // Run the compiler script via the Dart VM. |
| 1469 args = [compilerPath]; | 1473 args = [compilerPath]; |
| 1470 } else { | 1474 } else { |
| 1471 args = []; | 1475 args = []; |
| 1472 } | 1476 } |
| 1473 args.addAll(TestUtils.standardOptions(configuration)); | 1477 args.addAll(TestUtils.standardOptions(configuration)); |
| 1474 String packageRoot = packageRootArgument(optionsFromFile['packageRoot']); | 1478 String packages = packagesArgument(optionsFromFile['packageRoot'], |
| 1475 if (packageRoot != null) args.add(packageRoot); | 1479 optionsFromFile['packages']); |
| 1476 String packages = packagesArgument(optionsFromFile['packages']); | |
| 1477 if (packages != null) args.add(packages); | 1480 if (packages != null) args.add(packages); |
| 1478 args.add('--out=$outputFile'); | 1481 args.add('--out=$outputFile'); |
| 1479 args.add(inputFile); | 1482 args.add(inputFile); |
| 1480 List<String> options = optionsFromFile['sharedOptions']; | 1483 List<String> options = optionsFromFile['sharedOptions']; |
| 1481 if (options != null) args.addAll(options); | 1484 if (options != null) args.addAll(options); |
| 1482 return CommandBuilder.instance.getCompilationCommand( | 1485 return CommandBuilder.instance.getCompilationCommand( |
| 1483 compiler, | 1486 compiler, |
| 1484 outputFile, | 1487 outputFile, |
| 1485 !useSdk, | 1488 !useSdk, |
| 1486 dart2JsBootstrapDependencies, | 1489 dart2JsBootstrapDependencies, |
| 1487 compilerPath, | 1490 compilerPath, |
| 1488 args, | 1491 args, |
| 1489 environmentOverrides); | 1492 environmentOverrides); |
| 1490 } | 1493 } |
| 1491 | 1494 |
| 1492 /** Helper to create a Polymer deploy command for a single HTML file. */ | 1495 /** Helper to create a Polymer deploy command for a single HTML file. */ |
| 1493 Command _polymerDeployCommand( | 1496 Command _polymerDeployCommand( |
| 1494 String inputFile, String outputDir, optionsFromFile) { | 1497 String inputFile, String outputDir, optionsFromFile) { |
| 1495 List<String> args = []; | 1498 List<String> args = []; |
| 1496 String packageRoot = packageRootArgument(optionsFromFile['packageRoot']); | 1499 String packages = packagesArgument(optionsFromFile['packageRoot'], |
| 1497 if (packageRoot != null) args.add(packageRoot); | 1500 optionsFromFile['packages']); |
| 1498 String packages = packagesArgument(optionsFromFile['packages']); | |
| 1499 if (packages != null) args.add(packages); | 1501 if (packages != null) args.add(packages); |
| 1500 args | 1502 args |
| 1501 ..add('package:polymer/deploy.dart') | 1503 ..add('package:polymer/deploy.dart') |
| 1502 ..add('--test') | 1504 ..add('--test') |
| 1503 ..add(inputFile) | 1505 ..add(inputFile) |
| 1504 ..add('--out') | 1506 ..add('--out') |
| 1505 ..add(outputDir) | 1507 ..add(outputDir) |
| 1506 ..add('--file-filter') | 1508 ..add('--file-filter') |
| 1507 ..add('.svn'); | 1509 ..add('.svn'); |
| 1508 if (configuration['csp']) args.add('--csp'); | 1510 if (configuration['csp']) args.add('--csp'); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1543 final path = dartDir.append( | 1545 final path = dartDir.append( |
| 1544 '/client/tests/drt/Content Shell.app/Contents/MacOS/Content Shell'); | 1546 '/client/tests/drt/Content Shell.app/Contents/MacOS/Content Shell'); |
| 1545 return path.toNativePath(); | 1547 return path.toNativePath(); |
| 1546 } | 1548 } |
| 1547 return dartDir.append('client/tests/drt/content_shell').toNativePath(); | 1549 return dartDir.append('client/tests/drt/content_shell').toNativePath(); |
| 1548 } | 1550 } |
| 1549 | 1551 |
| 1550 List<String> commonArgumentsFromFile(Path filePath, Map optionsFromFile) { | 1552 List<String> commonArgumentsFromFile(Path filePath, Map optionsFromFile) { |
| 1551 List args = TestUtils.standardOptions(configuration); | 1553 List args = TestUtils.standardOptions(configuration); |
| 1552 | 1554 |
| 1553 String packageRoot = packageRootArgument(optionsFromFile['packageRoot']); | 1555 String packages = packagesArgument(optionsFromFile['packageRoot'], |
| 1554 if (packageRoot != null) { | 1556 optionsFromFile['packages']); |
| 1555 args.add(packageRoot); | |
| 1556 } | |
| 1557 String packages = packagesArgument(optionsFromFile['packages']); | |
| 1558 if (packages != null) { | 1557 if (packages != null) { |
| 1559 args.add(packages); | 1558 args.add(packages); |
| 1560 } | 1559 } |
| 1561 args.addAll(additionalOptions(filePath)); | 1560 args.addAll(additionalOptions(filePath)); |
| 1562 if (configuration['analyzer']) { | 1561 if (configuration['analyzer']) { |
| 1563 args.add('--machine'); | 1562 args.add('--machine'); |
| 1564 args.add('--no-hints'); | 1563 args.add('--no-hints'); |
| 1565 } | 1564 } |
| 1566 | 1565 |
| 1567 if (configuration["compiler"] == "dart2analyzer" && | 1566 if (configuration["compiler"] == "dart2analyzer" && |
| 1568 (filePath.filename.contains("dart2js") || | 1567 (filePath.filename.contains("dart2js") || |
| 1569 filePath.directoryPath.segments().last.contains('html_common'))) { | 1568 filePath.directoryPath.segments().last.contains('html_common'))) { |
| 1570 args.add("--use-dart2js-libraries"); | 1569 args.add("--use-dart2js-libraries"); |
| 1571 } | 1570 } |
| 1572 | 1571 |
| 1573 bool isMultitest = optionsFromFile["isMultitest"]; | 1572 bool isMultitest = optionsFromFile["isMultitest"]; |
| 1574 List<String> dartOptions = optionsFromFile["dartOptions"]; | 1573 List<String> dartOptions = optionsFromFile["dartOptions"]; |
| 1575 | 1574 |
| 1576 assert(!isMultitest || dartOptions == null); | 1575 assert(!isMultitest || dartOptions == null); |
| 1577 args.add(filePath.toNativePath()); | 1576 args.add(filePath.toNativePath()); |
| 1578 if (dartOptions != null) { | 1577 if (dartOptions != null) { |
| 1579 args.addAll(dartOptions); | 1578 args.addAll(dartOptions); |
| 1580 } | 1579 } |
| 1581 | 1580 |
| 1582 return args; | 1581 return args; |
| 1583 } | 1582 } |
| 1584 | 1583 |
| 1585 String packageRoot(String packageRootFromFile) { | 1584 String packagesArgument(String packageRootFromFile, |
| 1585 String packagesFromFile) { | |
|
Søren Gjesse
2016/08/15 06:12:58
Indentation.
| |
| 1586 if (packagesFromFile != null) { | |
| 1587 return "--packages=$packagesFromFile"; | |
| 1588 } | |
| 1586 if (packageRootFromFile == "none") { | 1589 if (packageRootFromFile == "none") { |
| 1587 return null; | 1590 return null; |
| 1588 } | 1591 } |
| 1589 String packageRoot = packageRootFromFile; | 1592 packageRootFromFile ??= "$buildDir/packages/"; |
| 1590 if (packageRootFromFile == null) { | 1593 return "--package-root=$packageRootFromFile"; |
| 1591 packageRoot = "$buildDir/packages/"; | |
| 1592 } | |
| 1593 return packageRoot; | |
| 1594 } | |
| 1595 | |
| 1596 String packageRootArgument(String packageRootFromFile) { | |
| 1597 var packageRootPath = packageRoot(packageRootFromFile); | |
| 1598 if (packageRootPath == null) { | |
| 1599 return null; | |
| 1600 } | |
| 1601 return "--package-root=$packageRootPath"; | |
| 1602 } | |
| 1603 | |
| 1604 String packagesArgument(String packagesFromFile) { | |
| 1605 if (packagesFromFile == null || packagesFromFile == "none") { | |
| 1606 return null; | |
| 1607 } | |
| 1608 return "--packages=$packagesFromFile"; | |
| 1609 } | 1594 } |
| 1610 | 1595 |
| 1611 /** | 1596 /** |
| 1612 * Special options for individual tests are currently specified in various | 1597 * Special options for individual tests are currently specified in various |
| 1613 * ways: with comments directly in test files, by using certain imports, or by | 1598 * ways: with comments directly in test files, by using certain imports, or by |
| 1614 * creating additional files in the test directories. | 1599 * creating additional files in the test directories. |
| 1615 * | 1600 * |
| 1616 * Here is a list of options that are used by 'test.dart' today: | 1601 * Here is a list of options that are used by 'test.dart' today: |
| 1617 * - Flags can be passed to the vm or dartium process that runs the test by | 1602 * - Flags can be passed to the vm or dartium process that runs the test by |
| 1618 * adding a comment to the test file: | 1603 * adding a comment to the test file: |
| (...skipping 868 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2487 } | 2472 } |
| 2488 if (path.length > WINDOWS_SHORTEN_PATH_LIMIT) { | 2473 if (path.length > WINDOWS_SHORTEN_PATH_LIMIT) { |
| 2489 ++shortNameCounter; | 2474 ++shortNameCounter; |
| 2490 var pathEnd = path.substring(path.length - WINDOWS_PATH_END_LENGTH); | 2475 var pathEnd = path.substring(path.length - WINDOWS_PATH_END_LENGTH); |
| 2491 path = "short${shortNameCounter}_$pathEnd"; | 2476 path = "short${shortNameCounter}_$pathEnd"; |
| 2492 } | 2477 } |
| 2493 } | 2478 } |
| 2494 return path; | 2479 return path; |
| 2495 } | 2480 } |
| 2496 } | 2481 } |
| OLD | NEW |