Support for debugging DDC tests under devtool

R=alanknight@google.com

Review URL: https://codereview.chromium.org/2501183002 .
This commit is contained in:
Vijay Menon 2016-11-14 15:21:12 -08:00
parent 2bec7b5adb
commit 22c27800b6

View file

@ -2,9 +2,23 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
/// This is a utility to run and debug an individual DDC compiled test.
/// Tests can be run with either node or devtool (a Chrome-based utility with
/// DOM APIs and developer tools support).
///
/// Install devtool via:
/// > npm install -g devtool
///
/// Run via:
/// > devtool tool/run.js -- corelib/apply2_test
/// or
/// > node tool/run.js corelib/apply2_test
///
/// See TODO below on async / unittest support.
var args = process.argv.slice(2);
if (args.length != 1) {
throw new Error("Usage: node test/run.js <test-module-name>");
throw new Error("Usage: devtool tool/run.js <test-module-name>");
}
var test = args[0];
@ -27,7 +41,13 @@ requirejs.config({
// TODO(vsm): Factor out test framework code in test/browser/language_tests.js
// and use here. Async tests and unittests won't work without it.
var sdk = requirejs('dart_sdk');
var module = requirejs(test);
test = test.split('/').slice(-1)[0];
module[test].main();
var lib = test.split('/').slice(-1)[0];
try {
module[lib].main();
console.log('Test ' + test + ' passed.');
} catch (e) {
console.log('Test ' + test + ' failed:\n' + e.toString());
sdk.dart.stackPrint(e);
}