Added DebugLogger to testing scripts.

Review URL: https://codereview.chromium.org//11962042

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@17291 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
kustermann@google.com 2013-01-18 16:45:20 +00:00
parent 56c3b90f06
commit d71f8ff86f
8 changed files with 75 additions and 11 deletions

1
.gitignore vendored
View file

@ -14,6 +14,7 @@
/out /out
/xcodebuild /xcodebuild
/.flaky.log /.flaky.log
/.debug.log
/*.Makefile /*.Makefile
/*.opensdf /*.opensdf
/*.pyc /*.pyc

View file

@ -121,7 +121,8 @@ def TestStep(name, mode, system, compiler, runtime, targets, flags):
'--runtime=' + runtime, '--runtime=' + runtime,
'--time', '--time',
'--use-sdk', '--use-sdk',
'--report']) '--report',
'--write-debug-log'])
# TODO(ricow/kustermann): Issue 7339 # TODO(ricow/kustermann): Issue 7339
if runtime == "safari": if runtime == "safari":
@ -136,7 +137,7 @@ def TestStep(name, mode, system, compiler, runtime, targets, flags):
if IsFirstTestStepCall: if IsFirstTestStepCall:
IsFirstTestStepCall = False IsFirstTestStepCall = False
else: else:
cmd.append('--append_flaky_log') cmd.append('--append_logs')
if flags: if flags:
cmd.extend(flags) cmd.extend(flags)

View file

@ -51,7 +51,7 @@ main() {
var printTiming = firstConf['time']; var printTiming = firstConf['time'];
var listTests = firstConf['list']; var listTests = firstConf['list'];
if (!firstConf['append_flaky_log']) { if (!firstConf['append_logs']) {
var file = new File(TestUtils.flakyFileName()); var file = new File(TestUtils.flakyFileName());
if (file.existsSync()) { if (file.existsSync()) {
file.deleteSync(); file.deleteSync();

View file

@ -30,6 +30,7 @@ import "testing/dart/test_options.dart";
import "testing/dart/test_suite.dart"; import "testing/dart/test_suite.dart";
import "testing/dart/test_progress.dart"; import "testing/dart/test_progress.dart";
import "testing/dart/http_server.dart"; import "testing/dart/http_server.dart";
import "testing/dart/utils.dart";
import "../compiler/tests/dartc/test_config.dart"; import "../compiler/tests/dartc/test_config.dart";
import "../runtime/tests/vm/test_config.dart"; import "../runtime/tests/vm/test_config.dart";
@ -82,13 +83,16 @@ main() {
var printTiming = firstConf['time']; var printTiming = firstConf['time'];
var listTests = firstConf['list']; var listTests = firstConf['list'];
if (!firstConf['append_flaky_log']) { if (!firstConf['append_logs']) {
var file = new File(TestUtils.flakyFileName()); var file = new File(TestUtils.flakyFileName());
if (file.existsSync()) { if (file.existsSync()) {
file.deleteSync(); file.deleteSync();
} }
} }
DebugLogger.init(firstConf['write_debug_log'] ?
TestUtils.debugLogfile() : null, append: firstConf['append_logs']);
// Print the configurations being run by this execution of // Print the configurations being run by this execution of
// test.dart. However, don't do it if the silent progress indicator // test.dart. However, don't do it if the silent progress indicator
// is used. This is only needed because of the junit tests. // is used. This is only needed because of the junit tests.
@ -146,13 +150,18 @@ main() {
} }
} }
void allTestsFinished() {
TestingServerRunner.terminateHttpServers();
DebugLogger.close();
}
// Start process queue. // Start process queue.
new ProcessQueue(maxProcesses, new ProcessQueue(maxProcesses,
progressIndicator, progressIndicator,
startTime, startTime,
printTiming, printTiming,
testSuites, testSuites,
() => TestingServerRunner.terminateHttpServers(), allTestsFinished,
verbose, verbose,
listTests); listTests);
} }

View file

@ -270,9 +270,17 @@ Note: currently only implemented for dart2js.''',
false, false,
'bool'), 'bool'),
new _TestOptionSpecification( new _TestOptionSpecification(
'append_flaky_log', 'append_logs',
'Do not delete the old flaky log but rather append to it.', 'Do not delete old logs but rather append to them.',
['--append_flaky_log'], ['--append_logs'],
[],
false,
'bool'
),
new _TestOptionSpecification(
'write_debug_log',
'Don\'t write debug messages to stdout but rather to a logfile.',
['--write-debug-log'],
[], [],
false, false,
'bool' 'bool'

View file

@ -1490,9 +1490,8 @@ class ProcessQueue {
_allDone(); _allDone();
if (browserUsed != '' && _seleniumServer != null) { if (browserUsed != '' && _seleniumServer != null) {
_seleniumServer.kill(); _seleniumServer.kill();
} else {
_progress.allDone();
} }
_progress.allDone();
} }
void _checkDone() { void _checkDone() {

View file

@ -1714,6 +1714,10 @@ class TestUtils {
return completer.future; return completer.future;
} }
static Path debugLogfile() {
return new Path(".debug.log");
}
static String flakyFileName() { static String flakyFileName() {
// If a flaky test did fail, infos about it (i.e. test name, stdin, stdout) // If a flaky test did fail, infos about it (i.e. test name, stdin, stdout)
// will be written to this file. This is useful for the debugging of // will be written to this file. This is useful for the debugging of

View file

@ -4,8 +4,50 @@
library utils; library utils;
import 'dart:io';
import 'dart:utf' as utf; import 'dart:utf' as utf;
class DebugLogger {
static OutputStream _stream;
/**
* If [path] was null, the DebugLogger will write messages to stdout.
*/
static init(Path path, {append: false}) {
if (path != null) {
var mode = append ? FileMode.APPEND : FileMode.WRITE;
_stream = new File.fromPath(path).openOutputStream(mode);
}
}
static void close() {
if (_stream != null) {
_stream.close();
_stream = null;
}
}
static void info(String msg) {
_print("Info: $msg");
}
static void warning(String msg) {
_print("Warning: $msg");
}
static void error(String msg) {
_print("Error: $msg");
}
static void _print(String msg) {
if (_stream != null) {
_stream.write(encodeUtf8(msg));
_stream.write([0x0a]);
} else {
print(msg);
}
}
}
List<int> encodeUtf8(String string) { List<int> encodeUtf8(String string) {
return utf.encodeUtf8(string); return utf.encodeUtf8(string);