9c0a6fd27c
It's added as a new compiler, so pass "-c dartdevk" to use it. It doesn't support any test packages yet, so tests that, say, import package expect won't compile. I'll work on that next, but it will require adding some stuff to the build scripts to build .dill files for those packages. This does get test.dart invoking the compiler, running the resulting test, and correctly reporting the result: - A test that doesn't throw an exception and stays within the bounds of what is currently implemented in dartdevk passes. - A test that compiles correctly but fails at runtime fails with a RuntimeError. - A test that contains a compile error fails with a non-zero exit code and is reported as a CompileTimeError. Change-Id: Icacbf1ff54dfe7aa4d245382d3b0aeb375cf105b Reviewed-on: https://dart-review.googlesource.com/15420 Commit-Queue: Bob Nystrom <rnystrom@google.com> Reviewed-by: Vijay Menon <vsm@google.com>
49 lines
1.5 KiB
Dart
Executable File
49 lines
1.5 KiB
Dart
Executable File
#!/usr/bin/env dart
|
|
// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
|
|
// 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.
|
|
|
|
/// Experimental command line entry point for Dart Development Compiler.
|
|
/// Unlike `dartdevc` this version uses the shared front end and IR.
|
|
import 'dart:async';
|
|
import 'dart:convert';
|
|
import 'dart:io';
|
|
|
|
import 'package:dev_compiler/src/kernel/command.dart';
|
|
|
|
Future main(List<String> args) async {
|
|
if (args.isNotEmpty && args.last == "--batch") {
|
|
await runBatch(args.sublist(0, args.length - 1));
|
|
} else {
|
|
var succeeded = await compile(args);
|
|
exitCode = succeeded ? 0 : 1;
|
|
}
|
|
}
|
|
|
|
/// Runs dartdevk in batch mode for test.dart.
|
|
Future runBatch(List<String> batchArgs) async {
|
|
var tests = 0;
|
|
var failed = 0;
|
|
var watch = new Stopwatch()..start();
|
|
|
|
print('>>> BATCH START');
|
|
|
|
String line;
|
|
while ((line = stdin.readLineSync(encoding: UTF8)).isNotEmpty) {
|
|
tests++;
|
|
var args = batchArgs.toList()..addAll(line.split(new RegExp(r'\s+')));
|
|
|
|
var succeeded = await compile(args);
|
|
|
|
// TODO(rnystrom): If kernel has any internal static state that needs to
|
|
// be cleared, do it here.
|
|
|
|
stderr.writeln('>>> EOF STDERR');
|
|
var outcome = succeeded ? 'PASS' : 'FAIL';
|
|
print('>>> TEST $outcome ${watch.elapsedMilliseconds}ms');
|
|
}
|
|
|
|
var time = watch.elapsedMilliseconds;
|
|
print('>>> BATCH END (${tests - failed})/$tests ${time}ms');
|
|
}
|