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

Side by Side Diff: client/testing/unittest/unittest_dartest.dart

Issue 8905021: Dartest CL - Please review (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years 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
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 /**
6 * A simple unit test library for running tests in a browser.
Bob Nystrom 2011/12/14 00:15:30 Update this comment to describe what this entrypoi
shauvik 2011/12/16 07:19:27 Done.
7 */
8 #library("unittest");
9
10 #import("dart:dom");
11
12 #source("shared.dart");
13
14 /** Getter for getting tests */
Bob Nystrom 2011/12/14 00:15:30 Obvious. Remove or make it say something I don't a
shauvik 2011/12/16 07:19:27 Ok - added more detail :) On 2011/12/14 00:15:30,
15 List<TestCase> get tests() => _tests;
16
17 int testsRun = 0, testsFailed = 0, testsErrors = 0;
Bob Nystrom 2011/12/14 00:15:30 We don't usually declare multiple variables on one
shauvik 2011/12/16 07:19:27 Done.
18 int get numTestsRun() => testsRun;
19 int get numTestsFailed() => testsFailed;
20 int get numTestsErrors() => testsErrors;
21
22 bool previousAsyncTest = false;
23
24 Function uiUpdator = null;
Bob Nystrom 2011/12/14 00:15:30 "updateUI".
shauvik 2011/12/16 07:19:27 Done.
25 set uiUpdateFunc(Function updateFunc) => uiUpdator = updateFunc;
Bob Nystrom 2011/12/14 00:15:30 Remove, you can just do "updateUI = ..."
shauvik 2011/12/16 07:19:27 Done.
26
27 Function dartestLogger = null;
28 set dartestLoggingFunc(Function logFunc) => dartestLogger = logFunc;
Bob Nystrom 2011/12/14 00:15:30 Remove.
shauvik 2011/12/16 07:19:27 Done.
29
30 _platformDefer(void callback()) {
31 _testRunner = runDARTests;
32 // DARTest ignores the callback. Tests are launched from UI
33 }
34
35 // Update test results
36 updateTestStats(TestCase test) {
37 assert(test.result != null);
38 if(test.startDate != null){
39 test.runningTime = (new Date.now()).difference(test.startDate);
40 }
41 testsRun++;
42 switch (test.result) {
43 case 'fail': testsFailed++; break;
44 case 'error': testsErrors++; break;
45 }
46 uiUpdator(test);
47 }
48
49 // Run tests sequentially
50 runDARTests(){
Bob Nystrom 2011/12/14 00:15:30 Dart shouldn't be all caps. "runDartests" or "runD
shauvik 2011/12/16 07:19:27 Done.
51 if(previousAsyncTest){
Bob Nystrom 2011/12/14 00:15:30 Space between "if" and "(". Also between ")" and "
shauvik 2011/12/16 07:19:27 Done.
52 updateTestStats(_tests[_currentTest-1]);
Bob Nystrom 2011/12/14 00:15:30 Space around "-".
shauvik 2011/12/16 07:19:27 Done.
53 previousAsyncTest = false;
54 }
55 if(_currentTest < _tests.length) {
56 final testCase = _tests[_currentTest];
57 dartestLogger('Running test:'+testCase.description);
Bob Nystrom 2011/12/14 00:15:30 Space around "+".
shauvik 2011/12/16 07:19:27 Done.
58 testCase.startingDate = new Date.now();
59 _runTest(testCase);
60 if (!testCase.isComplete && testCase.callbacks > 0) {
61 previousAsyncTest = true;
62 return;
63 }
64 updateTestStats(testCase);
65 _currentTest++;
66 window.setTimeout(runDARTests, 0);
67 }
68 }
69
70 _platformStartTests() {
71 //Support for VM and command line coming soon!
Bob Nystrom 2011/12/14 00:15:30 Make this a TODO comment: // TODO(shauvik): Suppo
shauvik 2011/12/16 07:19:27 Done.
72 window.console.log("Warning: Running DARTest from VM or Command-line.");
73 }
74
75 _platformInitialize() {
76 //Do nothing
Bob Nystrom 2011/12/14 00:15:30 Space after "//".
shauvik 2011/12/16 07:19:27 Done.
77 }
78
79 _platformCompleteTests(int testsPassed, int testsFailed, int testsErrors) {
80 //Do nothing
81 }
82
83 String getTestResultsCSV() {
Bob Nystrom 2011/12/14 00:15:30 "getTestResultsCsv".
shauvik 2011/12/16 07:19:27 Done.
84 StringBuffer out = new StringBuffer();
Bob Nystrom 2011/12/14 00:15:30 Just use "final" instead of a type annotation here
shauvik 2011/12/16 07:19:27 Done.
85 for(TestCase test in _tests) {
Bob Nystrom 2011/12/14 00:15:30 Space after "for".
shauvik 2011/12/16 07:19:27 Done.
86 String result = 'none';
87 if(test.result != null) {
88 result = test.result.toUpperCase();
89 }
90 out.add('${test.id}, "${test.description}", $result\n');
91 }
92 return out.toString();
93 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698