Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(218)

Unified Diff: tools/testing/dart/test_suite.dart

Issue 9240011: Add temporary directory for dartc compilation of tests. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Made test for temp directory a function. Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/testing/dart/test_runner.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/testing/dart/test_suite.dart
diff --git a/tools/testing/dart/test_suite.dart b/tools/testing/dart/test_suite.dart
index d4716b93464a65a2f1b664a6adb165e8d466910e..6a22d153b96f849f41a71bfc6d6ac320535a2f77 100644
--- a/tools/testing/dart/test_suite.dart
+++ b/tools/testing/dart/test_suite.dart
@@ -11,7 +11,8 @@
#source("browser_test.dart");
interface TestSuite {
- void forEachTest(Function onTest, Map testCache, [Function onDone]);
+ void forEachTest(Function onTest, Map testCache, String globalTempDir(),
+ [Function onDone]);
}
@@ -102,7 +103,8 @@ class CCTestSuite implements TestSuite {
}
}
- void forEachTest(Function onTest, Map testCache, [Function onDone]) {
+ void forEachTest(Function onTest, Map testCache, String globalTempDir(),
+ [Function onDone]) {
doTest = onTest;
doDone = (ignore) => (onDone != null) ? onDone() : null;
@@ -156,13 +158,14 @@ class StandardTestSuite implements TestSuite {
bool listingDone = false;
TestExpectations testExpectations;
List<TestInformation> cachedTests;
- final String pathSeparator;
+ final String dartDir;
+ Function globalTemporaryDirectory;
StandardTestSuite(Map this.configuration,
String this.suiteName,
String this.directoryPath,
List<String> this.statusFilePaths)
- : pathSeparator = new Platform().pathSeparator();
+ : dartDir = TestUtils.dartDir();
bool isTestFile(String filename) => filename.endsWith("Test.dart");
@@ -172,11 +175,13 @@ class StandardTestSuite implements TestSuite {
String shellPath() => TestUtils.dartShellFileName(configuration);
- List<String> additionalOptions() => [];
+ List<String> additionalOptions(String filename) => [];
- void forEachTest(Function onTest, Map testCache, [Function onDone = null]) {
+ void forEachTest(Function onTest, Map testCache, String globalTempDir(),
+ [Function onDone = null]) {
doTest = onTest;
doDone = (onDone != null) ? onDone : (() => null);
+ globalTemporaryDirectory = globalTempDir;
var filesRead = 0;
void statusFileRead() {
@@ -357,16 +362,6 @@ class StandardTestSuite implements TestSuite {
final String component = configuration['component'];
final String testPath = new File(filename).fullPathSync();
- String dartDir = new File('.').fullPathSync();
- if (!testPath.startsWith(dartDir) ||
- dartDir.endsWith('/frog')) {
- dartDir = new File('..').fullPathSync();
- if (!testPath.startsWith(dartDir)) {
- print('Run test.dart from the dart directory or' +
- ' an immediate subdirectory only.');
- Expect.fail('Could not find top level dart directory.');
- }
- }
for (var vmOptions in optionsFromFile['vmOptions']) {
// Create a unique temporary directory for each set of vmOptions.
@@ -379,7 +374,7 @@ class StandardTestSuite implements TestSuite {
.replaceAll('/','');
}
Directory tempDir =
- createTemporaryDirectory(testPath, dartDir, optionsName);
+ createTemporaryDirectory(testPath, optionsName);
String dartWrapperFilename = '${tempDir.path}/test.dart';
String compiledDartWrapperFilename = '${tempDir.path}/test.js';
@@ -495,25 +490,35 @@ class StandardTestSuite implements TestSuite {
}
}
+ bool get requiresCleanTemporaryDirectory() =>
+ configuration['component'] == 'dartc' ||
+ configuration['component'] == 'chromium';
+
/**
* Create a directory for the generated test. Drop the path to the
* dart checkout and the final ".dart" from the test path, and replace
* all path separators with underscores.
*/
Directory createTemporaryDirectory(String testPath,
Mads Ager (google) 2012/01/18 15:26:29 This confused me a little. Maybe we should call th
- String dartDir,
String optionsName) {
String testUniqueName =
testPath.substring(dartDir.length + 1, testPath.length - 5);
testUniqueName = testUniqueName.replaceAll('/', '_');
testUniqueName += '-$optionsName';
+
// Create '[build dir]/generated_tests/$component/$testUniqueName',
// including any intermediate directories that don't exist.
- var generatedTestPath = ['generated_tests',
+ String debugMode =
+ (configuration['mode'] == 'debug') ? 'Debug_' : 'Release_';
+ var generatedTestPath = [debugMode + configuration["arch"],
+ 'generated_tests',
configuration['component'],
testUniqueName];
String tempDirPath = TestUtils.buildDir(configuration);
+ if (requiresCleanTemporaryDirectory) {
+ tempDirPath = globalTemporaryDirectory();
+ }
Directory tempDir = new Directory(tempDirPath);
if (!tempDir.existsSync()) {
// Dartium tests can be run with no build step, with no output directory.
@@ -596,7 +601,7 @@ class StandardTestSuite implements TestSuite {
Map optionsFromFile,
bool enableFatalTypeErrors) {
List args = TestUtils.standardOptions(configuration);
- args.addAll(additionalOptions());
+ args.addAll(additionalOptions(filename));
if (enableFatalTypeErrors && configuration['component'] == 'dartc') {
args.add('--fatal-type-errors');
}
@@ -731,11 +736,9 @@ class DartcCompilationTestSuite extends StandardTestSuite {
String shellPath() => TestUtils.compilerPath(configuration);
- List<String> additionalOptions() {
- // TODO(ager): potentially register cleanup action to delete the temporary
- // directories?
- var tempDir = new Directory('');
- tempDir.createTempSync();
+ List<String> additionalOptions(String filename) {
+ filename = new File(filename).fullPathSync();
+ Directory tempDir = createTemporaryDirectory(filename, 'dartc-test');
return
[ '--fatal-warnings', '--fatal-type-errors',
'-check-only', '-out', tempDir.path];
@@ -768,7 +771,7 @@ class JUnitTestSuite implements TestSuite {
String suiteName;
String directoryPath;
String statusFilePath;
- String dartDir;
+ final String dartDir;
String buildDir;
String classPath;
List<String> testClasses;
@@ -779,7 +782,8 @@ class JUnitTestSuite implements TestSuite {
JUnitTestSuite(Map this.configuration,
String this.suiteName,
String this.directoryPath,
- String this.statusFilePath);
+ String this.statusFilePath)
+ : dartDir = TestUtils.dartDir();
bool isTestFile(String filename) => filename.endsWith("Tests.java") &&
!filename.contains('com/google/dart/compiler/vm') &&
@@ -787,6 +791,7 @@ class JUnitTestSuite implements TestSuite {
void forEachTest(Function onTest,
Map testCacheIgnored,
+ String globalTempDir(),
[Function onDone = null]) {
doTest = onTest;
doDone = (onDone != null) ? onDone : (() => null);
@@ -802,13 +807,6 @@ class JUnitTestSuite implements TestSuite {
return;
}
- dartDir = new File('.').fullPathSync();
- if (dartDir.endsWith('compiler')) {
- dartDir = new File('..').fullPathSync();
- if (!new File('$dartDir/tools/test.dart').existsSync()) {
- throw new Exception('Cannot find client checkout $dartDir');
- }
- }
buildDir = TestUtils.buildDir(configuration);
computeClassPath();
testClasses = <String>[];
@@ -961,6 +959,19 @@ class TestUtils {
return buildDir;
}
+ static String dartDir() {
+ Directory dart;
+ if (new File('tools/testing/dart/test_suite.dart').existsSync()) {
+ return new File('.').fullPathSync();
+ } else if (new File('../tools/testing/dart/test_suite.dart').existsSync()) {
+ return new File('..').fullPathSync();
+ } else {
+ print('Run test.dart from the dart directory or' +
+ ' an immediate subdirectory only.');
+ Expect.fail('Could not find top level dart directory.');
+ }
+ }
+
static List<String> standardOptions(Map configuration) {
List args = ["--ignore-unrecognized-flags"];
if (configuration["checked"]) {
« no previous file with comments | « tools/testing/dart/test_runner.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698