Skip to content

Commit

Permalink
Merge pull request #300 from Workiva/delete-confl-outputs-by-default
Browse files Browse the repository at this point in the history
Add test config option to delete conflicting outputs by default in Dart 2
  • Loading branch information
rmconsole7-wk authored Jun 11, 2019
2 parents 9cb1ff6 + 9146a79 commit cf3291e
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 9 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.dart_tool
.packages
.pub
.dart_tool
Expand Down Expand Up @@ -27,3 +28,4 @@ test_reports/
/test_fixtures/dart_x_only/doc/api/
/test_fixtures/docs/docs/doc/api/
/test_fixtures/format/changes_needed_temp/
/test_fixtures/needs_build_runner/.dart_tool
20 changes: 13 additions & 7 deletions lib/src/tasks/test/api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@ import 'package:dart_dev/src/util.dart'
show dartMajorVersion, dartiumExpirationOverrideEnv;
import 'package:dart_dev/util.dart' show hasImmediateDependency;

TestTask test(
{int concurrency,
List<String> platforms: const [],
List<String> presets: const [],
List<String> testArgs: const [],
List<String> tests: const []}) {
TestTask test({
int concurrency,
List<String> platforms: const [],
List<String> presets: const [],
List<String> testArgs: const [],
List<String> tests: const [],
}) {
final executable = 'pub';
final args = <String>[];

Expand All @@ -43,7 +44,12 @@ TestTask test(
}

if (hasImmediateDependency('build_test')) {
args.addAll(['run', 'build_runner', 'test', '--']);
args.addAll([
'run',
'build_runner',
'test',
'--',
]);
} else {
args.addAll(['run', 'test']);
}
Expand Down
16 changes: 14 additions & 2 deletions lib/src/tasks/test/cli.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ class TestCli extends TaskCli {
'Implies --concurrency=1 and --timeout=none.\n'
'Currently only supported for browser tests.',
negatable: false)
..addFlag('delete-conflicting-outputs',
help: 'Deletes conflicting outputs during the build', negatable: false)
..addOption('pub-serve-port',
help:
'Port used by the Pub server for browser tests. The default value will randomly select an open port to use.')
Expand Down Expand Up @@ -93,6 +95,7 @@ class TestCli extends TaskCli {

final testArgs = <String>[];
List<String> tests = [];
List<String> buildArgs = [];

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

bool deleteConflictingOutputs = TaskCli.valueOf(
'delete-conflicting-outputs',
parsedArgs,
config.test.deleteConflictingOutputs);

// CLI user can specify individual test files to run.
bool individualTestsSpecified = parsedArgs.rest.isNotEmpty;

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

if (deleteConflictingOutputs) {
buildArgs.add('--delete-conflicting-outputs');
}

if (dartMajorVersion == 2 && hasImmediateDependency('build_test')) {
final buildProcess =
new TaskProcess('pub', ['run', 'build_runner', 'build']);
var args = ['run', 'build_runner', 'build']..addAll(buildArgs);
final buildProcess = new TaskProcess('pub', args);
reporter.logGroup('pub run build_runner build',
outputStream: buildProcess.stdout, errorStream: buildProcess.stderr);
final buildExitCode = await buildProcess.exitCode;
Expand Down
2 changes: 2 additions & 0 deletions lib/src/tasks/test/config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import 'package:dart_dev/src/tasks/config.dart';
const List defaultAfterFunctional = const [];
const List defaultBeforeFunctional = const [];
const int defaultConcurrency = 4;
const bool defaultDeleteConflictingOutputs = false;
const bool defaultPauseAfterLoad = false;
const bool defaultPubServe = false;
const bool defaultDisableServeStdOut = false;
Expand All @@ -35,6 +36,7 @@ class TestConfig extends TaskConfig {
List afterFunctionalTests = defaultAfterFunctional;
List beforeFunctionalTests = defaultBeforeFunctional;
int concurrency = defaultConcurrency;
bool deleteConflictingOutputs = defaultDeleteConflictingOutputs;
List<String> functionalTests = defaultFunctionalTests;
List<String> integrationTests = defaultIntegrationTests;
List<String> platforms = defaultPlatforms;
Expand Down

0 comments on commit cf3291e

Please sign in to comment.