1
0
mirror of https://github.com/dart-lang/sdk synced 2024-07-08 20:16:39 +00:00

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
/xcodebuild
/.flaky.log
/.debug.log
/*.Makefile
/*.opensdf
/*.pyc

View File

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

View File

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

View File

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

View File

@ -270,9 +270,17 @@ Note: currently only implemented for dart2js.''',
false,
'bool'),
new _TestOptionSpecification(
'append_flaky_log',
'Do not delete the old flaky log but rather append to it.',
['--append_flaky_log'],
'append_logs',
'Do not delete old logs but rather append to them.',
['--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,
'bool'

View File

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

View File

@ -1714,6 +1714,10 @@ class TestUtils {
return completer.future;
}
static Path debugLogfile() {
return new Path(".debug.log");
}
static String flakyFileName() {
// 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

View File

@ -4,8 +4,50 @@
library utils;
import 'dart:io';
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) {
return utf.encodeUtf8(string);