Skip to content

Commit d7ef095

Browse files
authored
feat: Adding the dart test command (#1333)
* feat: Adding the dart test command * tests * fixig tests * more tests * improving tests even more * fixing some more tests * parameter adjustment * tweaks * additional tweaks * fix lint * PR suggestion
1 parent 42d8f9a commit d7ef095

18 files changed

+2678
-1539
lines changed

lib/src/cli/cli.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'dart:async';
2+
import 'dart:math';
23
import 'package:collection/collection.dart';
34
import 'package:glob/glob.dart';
45
import 'package:lcov_parser/lcov_parser.dart';
@@ -7,12 +8,13 @@ import 'package:meta/meta.dart';
78
import 'package:path/path.dart' as p;
89
import 'package:pubspec_parse/pubspec_parse.dart';
910
import 'package:universal_io/io.dart';
10-
import 'package:very_good_cli/src/commands/test/templates/templates.dart';
11+
import 'package:very_good_cli/src/cli/templates/templates.dart';
1112
import 'package:very_good_test_runner/very_good_test_runner.dart';
1213

1314
part 'dart_cli.dart';
1415
part 'flutter_cli.dart';
1516
part 'git_cli.dart';
17+
part 'test_cli_runner.dart';
1618

1719
const R Function<R>(
1820
R Function(), {

lib/src/cli/dart_cli.dart

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,41 @@ class Dart {
9292

9393
await Future.wait<void>(processes);
9494
}
95+
96+
/// Run tests (`dart test`).
97+
/// Returns a list of exit codes for each test process.
98+
static Future<List<int>> test({
99+
required Logger logger,
100+
String cwd = '.',
101+
bool recursive = false,
102+
bool collectCoverage = false,
103+
bool optimizePerformance = false,
104+
Set<String> ignore = const {},
105+
double? minCoverage,
106+
String? excludeFromCoverage,
107+
String? randomSeed,
108+
bool? forceAnsi,
109+
List<String>? arguments,
110+
void Function(String)? stdout,
111+
void Function(String)? stderr,
112+
GeneratorBuilder buildGenerator = MasonGenerator.fromBundle,
113+
}) async {
114+
return TestCLIRunner.test(
115+
logger: logger,
116+
testType: TestRunType.dart,
117+
cwd: cwd,
118+
recursive: recursive,
119+
collectCoverage: collectCoverage,
120+
optimizePerformance: optimizePerformance,
121+
ignore: ignore,
122+
minCoverage: minCoverage,
123+
excludeFromCoverage: excludeFromCoverage,
124+
randomSeed: randomSeed,
125+
forceAnsi: forceAnsi,
126+
arguments: arguments,
127+
stdout: stdout,
128+
stderr: stderr,
129+
buildGenerator: buildGenerator,
130+
);
131+
}
95132
}

0 commit comments

Comments
 (0)