Skip to content

Commit 68169c0

Browse files
Merge pull request #326 from Workiva/handle_dot_in_test_path_for_hfb
Remove `./` before sending test path to runner generation with hack-fast-builds flag
2 parents a10ec4b + 69fab26 commit 68169c0

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

lib/src/tasks/test/cli.dart

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -172,23 +172,28 @@ class TestCli extends TaskCli {
172172
'files/directories');
173173
}
174174

175-
final mapRunnerToContents = <File /*generated runner file*/, String /* contents */>{};
175+
final mapRunnerToContents =
176+
<File /*generated runner file*/, String /* contents */ >{};
176177
// Build the list of tests to run.
177178
if (individualTestsSpecified) {
178179
// Individual tests explicitly passed in should override the test suites.
179180
if (dartMajorVersion == 2 && parsedArgs[_hackFastBuilds]) {
180181
reporter.warning(
181182
'WARNING: You\'re using `${_hackFastBuilds}`. This will re-write the generated test runners in your repo.\n'
182-
'The test task will attempt to restore your generated runners after completion, but you may '
183-
'have to re-run `pub run dart_dev gen-test-runner` and `pub run dart_dev format` if your runners have changed.\n\n');
184-
final mapConfigToTestFiles = <TestRunnerConfig,
185-
Set<String> /* tests to include in runner */>{};
183+
'The test task will attempt to restore your generated runners after completion, but you may '
184+
'have to re-run `pub run dart_dev gen-test-runner` and `pub run dart_dev format` if your runners have changed.\n\n');
185+
final mapConfigToTestFiles =
186+
<TestRunnerConfig, Set<String> /* tests to include in runner */ >{};
186187
// Construct mapping from config to tests which should be ran in that config
187188
final copyOfConfigs = new List.from(config.genTestRunner.configs);
188189
for (final _config in copyOfConfigs) {
189-
for (final testFilePath in parsedArgs.rest) {
190+
for (var testFilePath in parsedArgs.rest) {
191+
if (testFilePath.startsWith('./')) {
192+
testFilePath = testFilePath.replaceFirst('./', '');
193+
}
190194
if (testFilePath.contains(_config.directory)) {
191-
mapConfigToTestFiles.putIfAbsent(_config, () => new Set.from([testFilePath]));
195+
mapConfigToTestFiles.putIfAbsent(
196+
_config, () => new Set.from([testFilePath]));
192197
mapConfigToTestFiles[_config].add(testFilePath);
193198
}
194199
}
@@ -197,7 +202,8 @@ class TestCli extends TaskCli {
197202
for (final _config in mapConfigToTestFiles.keys) {
198203
copyOfConfigs.remove(_config);
199204
final runnerFile = new File(_config.path);
200-
mapRunnerToContents.putIfAbsent(runnerFile, () => runnerFile.readAsStringSync());
205+
mapRunnerToContents.putIfAbsent(
206+
runnerFile, () => runnerFile.readAsStringSync());
201207
await genTestRunner(_config,
202208
filesToInclude: mapConfigToTestFiles[_config].toList());
203209
tests.add(_config.path);

0 commit comments

Comments
 (0)