OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 /// This is a utility to run and debug an individual DDC compiled test. |
| 6 /// Tests can be run with either node or devtool (a Chrome-based utility with |
| 7 /// DOM APIs and developer tools support). |
| 8 /// |
| 9 /// Install devtool via: |
| 10 /// > npm install -g devtool |
| 11 /// |
| 12 /// Run via: |
| 13 /// > devtool tool/run.js -- corelib/apply2_test |
| 14 /// or |
| 15 /// > node tool/run.js corelib/apply2_test |
| 16 /// |
| 17 /// See TODO below on async / unittest support. |
| 18 |
5 var args = process.argv.slice(2); | 19 var args = process.argv.slice(2); |
6 if (args.length != 1) { | 20 if (args.length != 1) { |
7 throw new Error("Usage: node test/run.js <test-module-name>"); | 21 throw new Error("Usage: devtool tool/run.js <test-module-name>"); |
8 } | 22 } |
9 var test = args[0]; | 23 var test = args[0]; |
10 | 24 |
11 var requirejs = require('requirejs'); | 25 var requirejs = require('requirejs'); |
12 var ddcdir = __dirname + '/../'; | 26 var ddcdir = __dirname + '/../'; |
13 requirejs.config({ | 27 requirejs.config({ |
14 baseUrl: ddcdir + 'gen/codegen_output', | 28 baseUrl: ddcdir + 'gen/codegen_output', |
15 paths: { | 29 paths: { |
16 dart_sdk: ddcdir + 'lib/js/amd/dart_sdk', | 30 dart_sdk: ddcdir + 'lib/js/amd/dart_sdk', |
17 async_helper: ddcdir + 'gen/codegen_output/pkg/async_helper', | 31 async_helper: ddcdir + 'gen/codegen_output/pkg/async_helper', |
18 expect: ddcdir + 'gen/codegen_output/pkg/expect', | 32 expect: ddcdir + 'gen/codegen_output/pkg/expect', |
19 js: ddcdir + 'gen/codegen_output/pkg/js', | 33 js: ddcdir + 'gen/codegen_output/pkg/js', |
20 matcher: ddcdir + 'gen/codegen_output/pkg/matcher', | 34 matcher: ddcdir + 'gen/codegen_output/pkg/matcher', |
21 minitest: ddcdir + 'gen/codegen_output/pkg/minitest', | 35 minitest: ddcdir + 'gen/codegen_output/pkg/minitest', |
22 path: ddcdir + 'gen/codegen_output/pkg/path', | 36 path: ddcdir + 'gen/codegen_output/pkg/path', |
23 stack_trace: ddcdir + 'gen/codegen_output/pkg/stack_trace', | 37 stack_trace: ddcdir + 'gen/codegen_output/pkg/stack_trace', |
24 unittest: ddcdir + 'gen/codegen_output/pkg/unittest', | 38 unittest: ddcdir + 'gen/codegen_output/pkg/unittest', |
25 } | 39 } |
26 }); | 40 }); |
27 | 41 |
28 // TODO(vsm): Factor out test framework code in test/browser/language_tests.js | 42 // TODO(vsm): Factor out test framework code in test/browser/language_tests.js |
29 // and use here. Async tests and unittests won't work without it. | 43 // and use here. Async tests and unittests won't work without it. |
30 | 44 var sdk = requirejs('dart_sdk'); |
31 var module = requirejs(test); | 45 var module = requirejs(test); |
32 test = test.split('/').slice(-1)[0]; | 46 var lib = test.split('/').slice(-1)[0]; |
33 module[test].main(); | 47 try { |
| 48 module[lib].main(); |
| 49 console.log('Test ' + test + ' passed.'); |
| 50 } catch (e) { |
| 51 console.log('Test ' + test + ' failed:\n' + e.toString()); |
| 52 sdk.dart.stackPrint(e); |
| 53 } |
OLD | NEW |