Files
sdk/pkg/dartdev/test/smoke/smoke_test.dart
T
Jaime Wren 70a3627d57 Update dartdev smoke tests for Dart version 2.12
I also took the time to
- add the smoke tests to the dartdev test_all.dart file
- change the order of the asserts to fail fast and with better messages if there are failures


Bug: https://github.com/dart-lang/sdk/issues/43842
Change-Id: Ic35e52145bf3f9d6871dcec07395966a02ca3d11
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168761
Reviewed-by: Leaf Petersen <leafp@google.com>
Commit-Queue: Jaime Wren <jwren@google.com>
2020-10-21 20:06:54 +00:00

95 lines
2.7 KiB
Dart

// Copyright (c) 2020, 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.
import 'dart:io';
import 'package:test/test.dart';
const numRuns = 10;
final script = Platform.script.resolve('smoke.dart').toString();
void main() {
group(
'explicit dartdev smoke -',
() {
test('dart run smoke.dart', () async {
for (int i = 1; i <= numRuns; ++i) {
if (i % 5 == 0) {
print('Done [$i/$numRuns]');
}
final result = await Process.run(
Platform.executable,
[
'run',
script,
],
);
expect(result.stderr, isEmpty);
expect(result.stdout, contains('Smoke test!'));
expect(result.exitCode, 0);
}
});
// This test forces DDS to spawn in a separate process.
test('dart run --enable-vm-service smoke.dart', () async {
for (int i = 1; i <= numRuns; ++i) {
if (i % 5 == 0) {
print('Done [$i/$numRuns]');
}
final result = await Process.run(
Platform.executable,
[
'run',
'--enable-vm-service=0',
script,
],
);
expect(result.stderr, isEmpty);
expect(result.stdout, contains('Smoke test!'));
expect(result.exitCode, 0);
}
});
// This test verifies that an error isn't thrown when a valid experiment
// is passed.
// Experiments are lists here:
// https://github.com/dart-lang/sdk/blob/master/tools/experimental_features.yaml
test(
'dart --enable-experiment=variance '
'run smoke.dart', () async {
final result = await Process.run(
Platform.executable,
[
'--enable-experiment=variance',
'run',
script,
],
);
expect(result.stderr, isEmpty);
expect(result.stdout, contains('Smoke test!'));
expect(result.exitCode, 0);
});
// This test verifies that an error is thrown when an invalid experiment
// is passed.
test(
'dart --enable-experiment=invalid-experiment-name '
'run smoke.dart', () async {
final result = await Process.run(
Platform.executable,
[
'--enable-experiment=invalid-experiment-name',
'run',
script,
],
);
expect(result.stderr, isNotEmpty);
expect(result.stdout, isEmpty);
expect(result.exitCode, 254);
});
},
timeout: Timeout.none,
);
}