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

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

Issue 9036009: Add client/tests/client web tests to the test.dart test script. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: small changes 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
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 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 filename.substring(middle + 1, filename.length - 5); 237 filename.substring(middle + 1, filename.length - 5);
238 } else { 238 } else {
239 // This case is hit by the dartc client compilation 239 // This case is hit by the dartc client compilation
240 // tests. These tests are pretty broken compared to the 240 // tests. These tests are pretty broken compared to the
241 // rest. They use the .dart suffix in the status files. They 241 // rest. They use the .dart suffix in the status files. They
242 // find tests in weird ways (testing that they contain "#"). 242 // find tests in weird ways (testing that they contain "#").
243 // They need to be redone. 243 // They need to be redone.
244 start = filename.indexOf(directoryPath); 244 start = filename.indexOf(directoryPath);
245 testName = filename.substring(start + directoryPath.length + 1, 245 testName = filename.substring(start + directoryPath.length + 1,
246 filename.length); 246 filename.length);
247 if (configuration['component'] != 'dartc') {
248 if (testName.endsWith('.dart')) {
249 testName = testName.substring(0, testName.length - 5);
250 }
251 }
247 } 252 }
248 Set<String> expectations = testExpectations.expectations(testName); 253 Set<String> expectations = testExpectations.expectations(testName);
249 if (configuration["report"]) { 254 if (configuration["report"]) {
250 // Tests with multiple VMOptions are counted more than once. 255 // Tests with multiple VMOptions are counted more than once.
251 for (var dummy in optionsFromFile["vmOptions"]) { 256 for (var dummy in optionsFromFile["vmOptions"]) {
252 SummaryReport.add(expectations); 257 SummaryReport.add(expectations);
253 } 258 }
254 } 259 }
255 if (expectations.contains(SKIP)) return; 260 if (expectations.contains(SKIP)) return;
256 261
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 bool isNegative) { 339 bool isNegative) {
335 if (optionsFromFile['isMultitest']) return; 340 if (optionsFromFile['isMultitest']) return;
336 bool isWebTest = optionsFromFile['containsDomImport']; 341 bool isWebTest = optionsFromFile['containsDomImport'];
337 bool isLibraryDefinition = optionsFromFile['isLibraryDefinition']; 342 bool isLibraryDefinition = optionsFromFile['isLibraryDefinition'];
338 if (!isLibraryDefinition && optionsFromFile['containsSourceOrImport']) { 343 if (!isLibraryDefinition && optionsFromFile['containsSourceOrImport']) {
339 print('Warning for $filename: Browser tests require #library ' + 344 print('Warning for $filename: Browser tests require #library ' +
340 'in any file that uses #import or #source'); 345 'in any file that uses #import or #source');
341 } 346 }
342 347
343 String tempDirTemplate = '${TestUtils.buildDir(configuration)}/tmp'; 348 String tempDirTemplate = '${TestUtils.buildDir(configuration)}/tmp';
344 if (isWebTest) tempDirTemplate = 'client/' + tempDirTemplate; 349 // if (isWebTest) tempDirTemplate = 'client/' + tempDirTemplate;
ahe 2012/01/02 10:42:23 Delete this line?
Bill Hesse 2012/01/02 12:50:42 Yes. But the real change should be to refactor, a
345 Directory tempDir = new Directory(tempDirTemplate); 350 Directory tempDir = new Directory(tempDirTemplate);
346 // TODO(whesse): When implementing client web tests, 351 // TODO(whesse): When implementing client web tests,
347 // create directory in the client case, if it doesn't exist. 352 // create directory in the client case, if it doesn't exist.
348 tempDir.createTempSync(); 353 tempDir.createTempSync();
349 354
350 String dartTestFilename = new File(filename).fullPathSync(); 355 String dartTestFilename = new File(filename).fullPathSync();
351 String dartWrapperFilename = '${tempDir.path}/test.dart'; 356 String dartWrapperFilename;
352 if (!isWebTest) { 357 String scriptPath;
358 if (isWebTest) {
359 scriptPath = 'file://$dartTestFilename';
ahe 2012/01/02 10:42:23 This doesn't work on Windows. Please add an abstra
Bill Hesse 2012/01/02 12:50:42 The Path and URI libraries are the next thing I wi
ahe 2012/01/02 13:00:59 SGTM, I guess a TODO would serve the same purpose.
360 } else {
361 dartWrapperFilename = '${tempDir.path}/test.dart';
362 scriptPath = '../../../$dartWrapperFilename';
353 // test.dart will import the dart test directly, if it is a library, 363 // test.dart will import the dart test directly, if it is a library,
354 // or indirectly through test_as_library.dart, if it is not. 364 // or indirectly through test_as_library.dart, if it is not.
355 String dartLibraryFilename; 365 String dartLibraryFilename;
356 if (isLibraryDefinition) { 366 if (isLibraryDefinition) {
357 dartLibraryFilename = dartTestFilename; 367 dartLibraryFilename = dartTestFilename;
358 } else { 368 } else {
359 dartLibraryFilename = 'test_as_library.dart'; 369 dartLibraryFilename = 'test_as_library.dart';
360 File file = new File('${tempDir.path}/$dartLibraryFilename'); 370 File file = new File('${tempDir.path}/$dartLibraryFilename');
361 RandomAccessFile dartLibrary = file.openSync(writable: true); 371 RandomAccessFile dartLibrary = file.openSync(writable: true);
362 dartLibrary.writeStringSync(WrapDartTestInLibrary(dartTestFilename)); 372 dartLibrary.writeStringSync(WrapDartTestInLibrary(dartTestFilename));
363 dartLibrary.closeSync(); 373 dartLibrary.closeSync();
364 } 374 }
365 375
ahe 2012/01/02 10:42:23 Trailing whitespace.
366 File file = new File(dartWrapperFilename); 376 File file = new File(dartWrapperFilename);
367 RandomAccessFile dartWrapper = file.openSync(writable: true); 377 RandomAccessFile dartWrapper = file.openSync(writable: true);
368 dartWrapper.writeStringSync(DartTestWrapper( 378 dartWrapper.writeStringSync(DartTestWrapper(
369 'dart:dom', 379 'dart:dom',
370 '../../../tests/isolate/src/TestFramework.dart', 380 '../../../tests/isolate/src/TestFramework.dart',
371 dartLibraryFilename)); 381 dartLibraryFilename));
372 dartWrapper.closeSync(); 382 dartWrapper.closeSync();
373 } else {
374 return; // TODO(whesse): Implement client web tests on dartium.
375 } 383 }
376 // Create the HTML file for the test. 384 // Create the HTML file for the test.
385 // NOTE: This must be 3 directories below the dart root, due to test
386 // client/samples/dartcombat containing a relative path to its .css file.
377 File htmlTestBase = new File('${tempDir.path}/${getHtmlName(filename)}'); 387 File htmlTestBase = new File('${tempDir.path}/${getHtmlName(filename)}');
378 RandomAccessFile htmlTest = htmlTestBase.openSync(writable: true); 388 RandomAccessFile htmlTest = htmlTestBase.openSync(writable: true);
379 htmlTest.writeStringSync(GetHtmlContents( 389 htmlTest.writeStringSync(GetHtmlContents(
380 filename, 390 filename,
381 '../../../client/testing/unittest/test_controller.js', 391 '../../../client/testing/unittest/test_controller.js',
382 scriptType, 392 scriptType,
383 '../../../$dartWrapperFilename')); 393 scriptPath));
384 htmlTest.closeSync(); 394 htmlTest.closeSync();
385 395
386 for (var vmOptions in optionsFromFile["vmOptions"]) { 396 for (var vmOptions in optionsFromFile["vmOptions"]) {
387 var drtFlags = ['-no-timeout']; 397 var drtFlags = ['--no-timeout'];
388 var dartFlags = ['--enable_asserts', '--enable_type_checks']; 398 var dartFlags = ['--enable_asserts', '--enable_type_checks'];
389 dartFlags.addAll(vmOptions); 399 dartFlags.addAll(vmOptions);
390 drtFlags.add('--dart-flags=${Strings.join(dartFlags, " ")}'); 400 drtFlags.add('--dart-flags=${Strings.join(dartFlags, " ")}');
391 var args = drtFlags; 401 var args = drtFlags;
392 args.add(htmlTestBase.fullPathSync()); 402 args.add(htmlTestBase.fullPathSync());
393 403
394 // Create BrowserTestCase and queue it. 404 // Create BrowserTestCase and queue it.
395 var testCase = new BrowserTestCase( 405 var testCase = new BrowserTestCase(
396 testName, 406 testName,
397 null, 407 null,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 String testRelativeDirFlattened; 440 String testRelativeDirFlattened;
431 441
432 int start = testRelativePath.lastIndexOf('src' + pathSeparator); 442 int start = testRelativePath.lastIndexOf('src' + pathSeparator);
433 if (start != -1) { 443 if (start != -1) {
434 Expect.isTrue(testRelativePath.endsWith('.dart')); 444 Expect.isTrue(testRelativePath.endsWith('.dart'));
435 testNameBase = 445 testNameBase =
436 testRelativePath.substring(start + 4, testRelativePath.length - 5); 446 testRelativePath.substring(start + 4, testRelativePath.length - 5);
437 testRelativeDir = testRelativePath.substring(0, start - 1); 447 testRelativeDir = testRelativePath.substring(0, start - 1);
438 testRelativeDirFlattened = testRelativeDir.replaceAll(pathSeparator, '_'); 448 testRelativeDirFlattened = testRelativeDir.replaceAll(pathSeparator, '_');
439 } else { 449 } else {
440 Expect.fail('Web tests not imlemented yet'); 450 Expect.isTrue(testRelativePath.endsWith('_tests.dart'));
451 start = testRelativePath.lastIndexOf(pathSeparator);
452 testNameBase =
453 testRelativePath.substring(start + 1, testRelativePath.length - 11);
441 } 454 }
442 455
443 if (!new Directory('$dartDir/$buildDir/generated_tests').existsSync()) { 456 if (!new Directory('$dartDir/$buildDir/generated_tests').existsSync()) {
444 new Directory('$dartDir/$buildDir/generated_tests').createSync(); 457 new Directory('$dartDir/$buildDir/generated_tests').createSync();
445 } 458 }
446 if (!new Directory(outputDirBase).existsSync()) { 459 if (!new Directory(outputDirBase).existsSync()) {
447 new Directory(outputDirBase).createSync(); 460 new Directory(outputDirBase).createSync();
448 } 461 }
449 Directory tempDir = new Directory( 462 Directory tempDir = new Directory(
450 '$outputDirBase/${testRelativeDirFlattened}_$testNameBase'); 463 '$outputDirBase/${testRelativeDirFlattened}_$testNameBase');
451 if (!tempDir.existsSync()) { 464 if (!tempDir.existsSync()) {
452 tempDir.createSync(); 465 tempDir.createSync();
453 } 466 }
454 467
455 String dartWrapperFilename = '${tempDir.path}/test.dart'; 468 String dartWrapperFilename = '${tempDir.path}/test.dart';
456 String compiledDartWrapperFilename = '${tempDir.path}/test.js'; 469 String compiledDartWrapperFilename = '${tempDir.path}/test.js';
457 String domLibraryImport = 'dart:dom'; 470 String domLibraryImport = 'dart:dom';
458 if (configuration['component'] == 'chromium') { 471 if (configuration['component'] == 'chromium') {
459 domLibraryImport = 472 domLibraryImport =
460 '$dartDir/client/testing/unittest/dom_for_unittest.dart'; 473 '$dartDir/client/testing/unittest/dom_for_unittest.dart';
461 } 474 }
462 475
476 File htmlTestBase;
463 if (!isWebTest) { 477 if (!isWebTest) {
464 // test.dart will import the dart test directly, if it is a library, 478 // test.dart will import the dart test directly, if it is a library,
465 // or indirectly through test_as_library.dart, if it is not. 479 // or indirectly through test_as_library.dart, if it is not.
466 String dartLibraryFilename; 480 String dartLibraryFilename;
467 if (isLibraryDefinition) { 481 if (isLibraryDefinition) {
468 dartLibraryFilename = testPath; 482 dartLibraryFilename = testPath;
469 } else { 483 } else {
470 dartLibraryFilename = 'test_as_library.dart'; 484 dartLibraryFilename = 'test_as_library.dart';
471 File file = new File('${tempDir.path}/$dartLibraryFilename'); 485 File file = new File('${tempDir.path}/$dartLibraryFilename');
472 RandomAccessFile dartLibrary = file.openSync(writable: true); 486 RandomAccessFile dartLibrary = file.openSync(writable: true);
473 dartLibrary.writeStringSync(WrapDartTestInLibrary(testPath)); 487 dartLibrary.writeStringSync(WrapDartTestInLibrary(testPath));
474 dartLibrary.closeSync(); 488 dartLibrary.closeSync();
475 } 489 }
476 490
477 File file = new File(dartWrapperFilename); 491 File file = new File(dartWrapperFilename);
478 RandomAccessFile dartWrapper = file.openSync(writable: true); 492 RandomAccessFile dartWrapper = file.openSync(writable: true);
479 dartWrapper.writeStringSync(DartTestWrapper( 493 dartWrapper.writeStringSync(DartTestWrapper(
480 domLibraryImport, 494 domLibraryImport,
481 '$dartDir/tests/isolate/src/TestFramework.dart', 495 '$dartDir/tests/isolate/src/TestFramework.dart',
482 dartLibraryFilename)); 496 dartLibraryFilename));
483 dartWrapper.closeSync(); 497 dartWrapper.closeSync();
498 htmlTestBase = new File('${tempDir.path}/${getHtmlName(filename)}');
484 } else { 499 } else {
485 return; // TODO(whesse): Implement client web tests on dartium. 500 dartWrapperFilename = testPath;
501 // TODO(whesse): Once test.py is retired, adjust the relative path in
502 // the client/samples/dartcombat test to its css file, remove the
503 // "../../" from this path, and move this out of the isWebTest guard.
504 htmlTestBase = new File('${tempDir.path}/../../${getHtmlName(filename)}');
505 // return; // TODO(whesse): Implement client web tests on dartium.
ahe 2012/01/02 10:42:23 Remove this line.
486 } 506 }
487 // Create the HTML file for the test. 507 // Create the HTML file for the test.
488 File htmlTestBase = new File('${tempDir.path}/${getHtmlName(filename)}');
489 RandomAccessFile htmlTest = htmlTestBase.openSync(writable: true); 508 RandomAccessFile htmlTest = htmlTestBase.openSync(writable: true);
490 htmlTest.writeStringSync(GetHtmlContents( 509 htmlTest.writeStringSync(GetHtmlContents(
491 filename, 510 filename,
492 '$dartDir/client/testing/unittest/test_controller.js', 511 '$dartDir/client/testing/unittest/test_controller.js',
493 scriptType, 512 scriptType,
494 compiledDartWrapperFilename)); 513 compiledDartWrapperFilename));
495 htmlTest.closeSync(); 514 htmlTest.closeSync();
496 515
497 for (var vmOptions in optionsFromFile["vmOptions"]) { 516 for (var vmOptions in optionsFromFile["vmOptions"]) {
498 List<String> compilerArgs; 517 List<String> compilerArgs;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 return tempDir.path + 'test.js'; 580 return tempDir.path + 'test.js';
562 default: 581 default:
563 Expect.fail('Unimplemented component scriptType'); 582 Expect.fail('Unimplemented component scriptType');
564 return null; 583 return null;
565 } 584 }
566 } 585 }
567 586
568 String getHtmlName(String filename) { 587 String getHtmlName(String filename) {
569 switch (configuration['component']) { 588 switch (configuration['component']) {
570 case 'dartium': 589 case 'dartium':
571 return filename.replaceAll(pathSeparator, '_') + 'dartium.html'; 590 return filename.replaceAll(pathSeparator, '_') + 'dartium.html';
ahe 2012/01/02 10:42:23 This doesn't work on Windows. Consider that a wind
Bill Hesse 2012/01/02 12:50:42 Aaarrrrgh.
Bill Hesse 2012/01/03 15:01:35 Now all arguments to this have only forward slashe
572 case 'chromium': 591 case 'chromium':
592 return filename.replaceAll(pathSeparator, '_') + 'chromium.html';
ahe 2012/01/02 10:42:23 Ditto.
573 case 'frogium': 593 case 'frogium':
574 return 'test.html'; 594 return filename.replaceAll(pathSeparator, '_') + 'frogium.html';
ahe 2012/01/02 10:42:23 Ditto.
575 default: 595 default:
576 Expect.fail('Unimplemented component scriptType'); 596 Expect.fail('Unimplemented component scriptType');
577 return null; 597 return null;
578 } 598 }
579 } 599 }
580 600
581 String get dumpRenderTreeFilename() { 601 String get dumpRenderTreeFilename() {
582 if (new Platform().operatingSystem() == 'macos') { 602 if (new Platform().operatingSystem() == 'macos') {
583 return 'client/tests/drt/DumpRenderTree.app/Contents/' + 603 return 'client/tests/drt/DumpRenderTree.app/Contents/' +
584 'MacOS/DumpRenderTree'; 604 'MacOS/DumpRenderTree';
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
907 * $noCrash tests are expected to be flaky but not crash 927 * $noCrash tests are expected to be flaky but not crash
908 * $pass tests are expected to pass 928 * $pass tests are expected to pass
909 * $failOk tests are expected to fail that we won't fix 929 * $failOk tests are expected to fail that we won't fix
910 * $fail tests are expected to fail that we should fix 930 * $fail tests are expected to fail that we should fix
911 * $crash tests are expected to crash that we should fix 931 * $crash tests are expected to crash that we should fix
912 * $timeout tests are allowed to timeout\ 932 * $timeout tests are allowed to timeout\
913 """; 933 """;
914 print(report); 934 print(report);
915 } 935 }
916 } 936 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698