Skip to content

Commit cf3291e

Browse files
Merge pull request #300 from Workiva/delete-confl-outputs-by-default
Add test config option to delete conflicting outputs by default in Dart 2
2 parents 9cb1ff6 + 9146a79 commit cf3291e

File tree

4 files changed

+31
-9
lines changed

4 files changed

+31
-9
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
.dart_tool
12
.packages
23
.pub
34
.dart_tool
@@ -27,3 +28,4 @@ test_reports/
2728
/test_fixtures/dart_x_only/doc/api/
2829
/test_fixtures/docs/docs/doc/api/
2930
/test_fixtures/format/changes_needed_temp/
31+
/test_fixtures/needs_build_runner/.dart_tool

lib/src/tasks/test/api.dart

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,13 @@ import 'package:dart_dev/src/util.dart'
2424
show dartMajorVersion, dartiumExpirationOverrideEnv;
2525
import 'package:dart_dev/util.dart' show hasImmediateDependency;
2626

27-
TestTask test(
28-
{int concurrency,
29-
List<String> platforms: const [],
30-
List<String> presets: const [],
31-
List<String> testArgs: const [],
32-
List<String> tests: const []}) {
27+
TestTask test({
28+
int concurrency,
29+
List<String> platforms: const [],
30+
List<String> presets: const [],
31+
List<String> testArgs: const [],
32+
List<String> tests: const [],
33+
}) {
3334
final executable = 'pub';
3435
final args = <String>[];
3536

@@ -43,7 +44,12 @@ TestTask test(
4344
}
4445

4546
if (hasImmediateDependency('build_test')) {
46-
args.addAll(['run', 'build_runner', 'test', '--']);
47+
args.addAll([
48+
'run',
49+
'build_runner',
50+
'test',
51+
'--',
52+
]);
4753
} else {
4854
args.addAll(['run', 'test']);
4955
}

lib/src/tasks/test/cli.dart

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ class TestCli extends TaskCli {
5555
'Implies --concurrency=1 and --timeout=none.\n'
5656
'Currently only supported for browser tests.',
5757
negatable: false)
58+
..addFlag('delete-conflicting-outputs',
59+
help: 'Deletes conflicting outputs during the build', negatable: false)
5860
..addOption('pub-serve-port',
5961
help:
6062
'Port used by the Pub server for browser tests. The default value will randomly select an open port to use.')
@@ -93,6 +95,7 @@ class TestCli extends TaskCli {
9395

9496
final testArgs = <String>[];
9597
List<String> tests = [];
98+
List<String> buildArgs = [];
9699

97100
if (!color) {
98101
testArgs.add('--no-color');
@@ -123,6 +126,11 @@ class TestCli extends TaskCli {
123126
List<String> presets =
124127
TaskCli.valueOf('preset', parsedArgs, const <String>[]);
125128

129+
bool deleteConflictingOutputs = TaskCli.valueOf(
130+
'delete-conflicting-outputs',
131+
parsedArgs,
132+
config.test.deleteConflictingOutputs);
133+
126134
// CLI user can specify individual test files to run.
127135
bool individualTestsSpecified = parsedArgs.rest.isNotEmpty;
128136

@@ -184,9 +192,13 @@ class TestCli extends TaskCli {
184192
testArgs.add('--pause-after-load');
185193
}
186194

195+
if (deleteConflictingOutputs) {
196+
buildArgs.add('--delete-conflicting-outputs');
197+
}
198+
187199
if (dartMajorVersion == 2 && hasImmediateDependency('build_test')) {
188-
final buildProcess =
189-
new TaskProcess('pub', ['run', 'build_runner', 'build']);
200+
var args = ['run', 'build_runner', 'build']..addAll(buildArgs);
201+
final buildProcess = new TaskProcess('pub', args);
190202
reporter.logGroup('pub run build_runner build',
191203
outputStream: buildProcess.stdout, errorStream: buildProcess.stderr);
192204
final buildExitCode = await buildProcess.exitCode;

lib/src/tasks/test/config.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import 'package:dart_dev/src/tasks/config.dart';
1919
const List defaultAfterFunctional = const [];
2020
const List defaultBeforeFunctional = const [];
2121
const int defaultConcurrency = 4;
22+
const bool defaultDeleteConflictingOutputs = false;
2223
const bool defaultPauseAfterLoad = false;
2324
const bool defaultPubServe = false;
2425
const bool defaultDisableServeStdOut = false;
@@ -35,6 +36,7 @@ class TestConfig extends TaskConfig {
3536
List afterFunctionalTests = defaultAfterFunctional;
3637
List beforeFunctionalTests = defaultBeforeFunctional;
3738
int concurrency = defaultConcurrency;
39+
bool deleteConflictingOutputs = defaultDeleteConflictingOutputs;
3840
List<String> functionalTests = defaultFunctionalTests;
3941
List<String> integrationTests = defaultIntegrationTests;
4042
List<String> platforms = defaultPlatforms;

0 commit comments

Comments
 (0)