Skip to content
Snippets Groups Projects
Unverified Commit dc00299a authored by Natalie Weizenbaum's avatar Natalie Weizenbaum Committed by GitHub
Browse files

Warn when running VM or Node tests with --precompiled (#789)

Closes #784
parent e9826969
No related branches found
No related tags found
No related merge requests found
......@@ -244,6 +244,12 @@ class Loader {
var name = (platform.runtime.isJS ? "compiling " : "loading ") + path;
yield new LoadSuite(name, platformConfig, platform, () async {
if (platformConfig.precompiledPath != null &&
!platform.runtime.isBrowser) {
warn("--precompiled is only supported for browser platforms.",
print: true);
}
var memo = _platformPlugins[platform.runtime];
try {
......
......@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
import 'dart:async';
import 'dart:core' as core;
import 'dart:core';
import 'dart:convert';
import 'dart:io';
......@@ -171,10 +173,13 @@ String wordWrap(String text) {
/// This automatically wraps lines if they get too long. If [color] is passed,
/// it controls whether the warning header is color; otherwise, it defaults to
/// [canUseSpecialChars].
void warn(String message, {bool color}) {
///
/// If [print] is `true`, this prints the message using [print] to associate it
/// with the current test. Otherwise, it prints it using [stderr].
void warn(String message, {bool color, bool print: false}) {
if (color == null) color = canUseSpecialChars;
var header = color ? "\u001b[33mWarning:\u001b[0m" : "Warning:";
stderr.writeln(wordWrap("$header $message\n"));
(print ? core.print : stderr.writeln)(wordWrap("$header $message\n"));
}
/// Repeatedly finds a probably-unused port on localhost and passes it to
......
......@@ -217,6 +217,20 @@ void main() {
await test.shouldExit(1);
});
test("prints a warning with --precompiled", () async {
await d.file("test.dart", _success).create();
var test = await runTest(["-p", "node", "--precompiled=.", "test.dart"]);
expect(
test.stdout,
containsInOrder([
'+0: compiling test.dart',
'Warning: --precompiled is only supported for browser platforms.',
'+1: All tests passed!'
]));
await test.shouldExit(0);
});
test("supports node_modules in the package directory", () async {
await d.dir("node_modules", [
d.dir("my_module", [d.file("index.js", "module.exports.value = 12;")])
......
......@@ -435,6 +435,20 @@ $_usage""");
await test.shouldExit(1);
});
test("warns for VM tests with --precompiled", () async {
await d.file("test.dart", _success).create();
var test = await runTest(["--precompiled=.", "test.dart"]);
expect(
test.stdout,
containsInOrder([
'+0: loading test.dart',
'Warning: --precompiled is only supported for browser platforms.',
'+1: All tests passed!'
]));
await test.shouldExit(0);
});
group("with a top-level @Skip declaration", () {
setUp(() async {
await d.file("test.dart", '''
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment