Files
sdk/pkg/kernel/test/self_check_util.dart
T
Johnni Winther 34fb48bb8a [kernel,front_end] Migrate first wave of pkg/kernel and pkg/front_end
Migrates libraries dependent only on already migrated libraries.

Change-Id: I0e85ee8dbc2afce031b92e0009e71c206a55af28
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/179502
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2021-01-18 15:40:21 +00:00

39 lines
1.1 KiB
Dart

// Copyright (c) 2016, 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.
// @dart = 2.9
import 'dart:async';
import 'package:kernel/src/tool/batch_util.dart';
/// Wraps a main() method for a test that should be runnable as a self-checking
/// unit test.
///
/// These tests can be run like:
///
/// tools/test.py -cdartk -rself_check
///
/// The test can either be run with a single file passed on the command line
/// or run in batch mode.
runSelfCheck(List<String> args, void runTest(String filename)) {
Future<CompilerOutcome> batchMain(List<String> arguments) async {
if (arguments.length != 1) {
throw 'Exactly one argument expected';
}
String filename = arguments[0];
if (!filename.endsWith('.dill')) {
throw 'File does not have expected .dill extension: $filename';
}
runTest(filename);
return CompilerOutcome.Ok;
}
if (args.length == 1 && args[0] == '--batch') {
runBatch(batchMain);
} else {
batchMain(args);
}
}