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

Side by Side Diff: tools/testing/dart/test_suite.dart

Issue 9148007: Create multiple temporary directories in test.dart for multiple vmOptions in a test. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 #library("test_suite"); 5 #library("test_suite");
6 6
7 #import("status_file_parser.dart"); 7 #import("status_file_parser.dart");
8 #import("test_runner.dart"); 8 #import("test_runner.dart");
9 #import("multitest.dart"); 9 #import("multitest.dart");
10 10
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 if (!testPath.startsWith(dartDir) || 355 if (!testPath.startsWith(dartDir) ||
356 dartDir.endsWith('/frog')) { 356 dartDir.endsWith('/frog')) {
357 dartDir = new File('..').fullPathSync(); 357 dartDir = new File('..').fullPathSync();
358 if (!testPath.startsWith(dartDir)) { 358 if (!testPath.startsWith(dartDir)) {
359 print('Run test.dart from the dart directory or' + 359 print('Run test.dart from the dart directory or' +
360 ' an immediate subdirectory only.'); 360 ' an immediate subdirectory only.');
361 Expect.fail('Could not find top level dart directory.'); 361 Expect.fail('Could not find top level dart directory.');
362 } 362 }
363 } 363 }
364 364
365 Directory tempDir = createTemporaryDirectory(testPath, dartDir); 365 for (var vmOptions in optionsFromFile['vmOptions']) {
366 // Create a unique temporary directory for each set of vmOptions.
367 // TODO(whesse): Replace separate replaces with a RegExp when
368 // replaceAll(RegExp, String) is implemented.
369 String optionsName = '';
370 if (optionsFromFile['vmOptions'].length > 1) {
371 optionsName = Strings.join(vmOptions, '-').replaceAll('-','')
372 .replaceAll('=','')
373 .replaceAll('/','');
374 }
375 Directory tempDir =
376 createTemporaryDirectory(testPath, dartDir, optionsName);
366 377
367 String dartWrapperFilename = '${tempDir.path}/test.dart'; 378 String dartWrapperFilename = '${tempDir.path}/test.dart';
368 String compiledDartWrapperFilename = '${tempDir.path}/test.js'; 379 String compiledDartWrapperFilename = '${tempDir.path}/test.js';
369 String domLibraryImport = (component == 'chromium') ? 380 String domLibraryImport = (component == 'chromium') ?
370 '$dartDir/client/testing/unittest/dom_for_unittest.dart' : 'dart:dom'; 381 '$dartDir/client/testing/unittest/dom_for_unittest.dart' : 'dart:dom';
371 382
372 String htmlPath = '${tempDir.path}/test.html'; 383 String htmlPath = '${tempDir.path}/test.html';
373 if (!isWebTest) { 384 if (!isWebTest) {
374 // test.dart will import the dart test directly, if it is a library, 385 // test.dart will import the dart test directly, if it is a library,
375 // or indirectly through test_as_library.dart, if it is not. 386 // or indirectly through test_as_library.dart, if it is not.
376 String dartLibraryFilename; 387 String dartLibraryFilename;
377 if (isLibraryDefinition) { 388 if (isLibraryDefinition) {
378 dartLibraryFilename = testPath; 389 dartLibraryFilename = testPath;
390 } else {
391 dartLibraryFilename = 'test_as_library.dart';
392 File file = new File('${tempDir.path}/$dartLibraryFilename');
393 RandomAccessFile dartLibrary = file.openSync(FileMode.WRITE);
394 dartLibrary.writeStringSync(WrapDartTestInLibrary(testPath));
395 dartLibrary.closeSync();
396 }
397
398 File file = new File(dartWrapperFilename);
399 RandomAccessFile dartWrapper = file.openSync(FileMode.WRITE);
400 dartWrapper.writeStringSync(DartTestWrapper(
401 domLibraryImport,
402 '$dartDir/tests/isolate/src/TestFramework.dart',
403 dartLibraryFilename));
404 dartWrapper.closeSync();
379 } else { 405 } else {
380 dartLibraryFilename = 'test_as_library.dart'; 406 dartWrapperFilename = testPath;
381 File file = new File('${tempDir.path}/$dartLibraryFilename'); 407 // TODO(whesse): Once test.py is retired, adjust the relative path in
382 RandomAccessFile dartLibrary = file.openSync(FileMode.WRITE); 408 // the client/samples/dartcombat test to its css file, remove the
383 dartLibrary.writeStringSync(WrapDartTestInLibrary(testPath)); 409 // "../../" from this path, and move this out of the isWebTest guard.
384 dartLibrary.closeSync(); 410 // Also remove getHtmlName, and just use test.html.
385 } 411 htmlPath = '${tempDir.path}/../../${getHtmlName(filename)}';
386 412 }
387 File file = new File(dartWrapperFilename); 413 final String scriptPath = (component == 'dartium') ?
388 RandomAccessFile dartWrapper = file.openSync(FileMode.WRITE); 414 dartWrapperFilename : compiledDartWrapperFilename;
389 dartWrapper.writeStringSync(DartTestWrapper( 415 // Create the HTML file for the test.
390 domLibraryImport, 416 RandomAccessFile htmlTest = new File(htmlPath).openSync(FileMode.WRITE);
391 '$dartDir/tests/isolate/src/TestFramework.dart', 417 htmlTest.writeStringSync(GetHtmlContents(
392 dartLibraryFilename)); 418 filename,
393 dartWrapper.closeSync(); 419 '$dartDir/client/testing/unittest/test_controller.js',
394 } else { 420 scriptType,
395 dartWrapperFilename = testPath; 421 scriptPath));
396 // TODO(whesse): Once test.py is retired, adjust the relative path in 422 htmlTest.closeSync();
397 // the client/samples/dartcombat test to its css file, remove the
398 // "../../" from this path, and move this out of the isWebTest guard.
399 // Also remove getHtmlName, and just use test.html.
400 htmlPath = '${tempDir.path}/../../${getHtmlName(filename)}';
401 }
402 final String scriptPath = (component == 'dartium') ?
403 dartWrapperFilename : compiledDartWrapperFilename;
404 // Create the HTML file for the test.
405 RandomAccessFile htmlTest = new File(htmlPath).openSync(FileMode.WRITE);
406 htmlTest.writeStringSync(GetHtmlContents(
407 filename,
408 '$dartDir/client/testing/unittest/test_controller.js',
409 scriptType,
410 scriptPath));
411 htmlTest.closeSync();
412 423
413 for (var vmOptions in optionsFromFile['vmOptions']) {
414 List<String> compilerArgs = TestUtils.standardOptions(configuration); 424 List<String> compilerArgs = TestUtils.standardOptions(configuration);
415 String compilerExecutable = TestUtils.compilerPath(configuration); 425 String compilerExecutable = TestUtils.compilerPath(configuration);
416 switch (component) { 426 switch (component) {
417 case 'chromium': 427 case 'chromium':
418 compilerArgs.addAll(['--work', tempDir.path]); 428 compilerArgs.addAll(['--work', tempDir.path]);
419 if (configuration['mode'] == 'release') { 429 if (configuration['mode'] == 'release') {
420 compilerArgs.add('--optimize'); 430 compilerArgs.add('--optimize');
421 } 431 }
422 compilerArgs.addAll(vmOptions); 432 compilerArgs.addAll(vmOptions);
423 compilerArgs.add('--ignore-unrecognized-flags'); 433 compilerArgs.add('--ignore-unrecognized-flags');
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 doTest(testCase); 503 doTest(testCase);
494 } 504 }
495 } 505 }
496 506
497 /*** 507 /***
498 * Create a directory for the generated test. Drop the path to the 508 * Create a directory for the generated test. Drop the path to the
499 * dart checkout and the final ".dart" from the test path, and replace 509 * dart checkout and the final ".dart" from the test path, and replace
500 * all path separators with underscores. 510 * all path separators with underscores.
501 * All variables are block local, except tempDir. 511 * All variables are block local, except tempDir.
502 */ 512 */
503 Directory createTemporaryDirectory(String testPath, String dartDir) 513 Directory createTemporaryDirectory(String testPath,
514 String dartDir,
515 String optionsName)
504 { 516 {
505 String testUniqueName = 517 String testUniqueName =
506 testPath.substring(dartDir.length + 1, testPath.length - 5); 518 testPath.substring(dartDir.length + 1, testPath.length - 5);
507 testUniqueName = testUniqueName.replaceAll('/', '_'); 519 testUniqueName = testUniqueName.replaceAll('/', '_');
520 testUniqueName += '-$optionsName';
508 // Create '[build dir]/generated_tests/$component/$testUniqueName', 521 // Create '[build dir]/generated_tests/$component/$testUniqueName',
509 // including any intermediate directories that don't exist. 522 // including any intermediate directories that don't exist.
510 var generatedTestPath = ['generated_tests', 523 var generatedTestPath = ['generated_tests',
511 configuration['component'], 524 configuration['component'],
512 testUniqueName]; 525 testUniqueName];
513 526
514 String tempDirPath = TestUtils.buildDir(configuration); 527 String tempDirPath = TestUtils.buildDir(configuration);
515 Directory tempDir = new Directory(tempDirPath); 528 Directory tempDir = new Directory(tempDirPath);
516 if (!tempDir.existsSync()) { 529 if (!tempDir.existsSync()) {
517 // Dartium tests can be run with no build step, with no output directory. 530 // Dartium tests can be run with no build step, with no output directory.
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after
1013 * $noCrash tests are expected to be flaky but not crash 1026 * $noCrash tests are expected to be flaky but not crash
1014 * $pass tests are expected to pass 1027 * $pass tests are expected to pass
1015 * $failOk tests are expected to fail that we won't fix 1028 * $failOk tests are expected to fail that we won't fix
1016 * $fail tests are expected to fail that we should fix 1029 * $fail tests are expected to fail that we should fix
1017 * $crash tests are expected to crash that we should fix 1030 * $crash tests are expected to crash that we should fix
1018 * $timeout tests are allowed to timeout\ 1031 * $timeout tests are allowed to timeout\
1019 """; 1032 """;
1020 print(report); 1033 print(report);
1021 } 1034 }
1022 } 1035 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698