creating test result directory before running tests (flutter/engine#21324)

* creating test result directory. adding a prepare method to test runner

* addressing reviewer comments
This commit is contained in:
nturgut
2020-09-22 12:51:14 -07:00
committed by GitHub
parent 6cf89de868
commit 39dd63661e
3 changed files with 25 additions and 17 deletions

View File

@@ -168,6 +168,13 @@ class Environment {
'goldens',
));
/// Directory to add test results which would later be uploaded to a gcs
/// bucket by LUCI.
io.Directory get webUiTestResultsDirectory => io.Directory(pathlib.join(
webUiDartToolDir.path,
'test_results',
));
/// Path to the screenshots taken by iOS simulator.
io.Directory get webUiSimulatorScreenshotsDirectory =>
io.Directory(pathlib.join(

View File

@@ -248,17 +248,8 @@ To automatically create this file call matchGoldenFile('$filename', write: true)
);
if (diff.rate > 0) {
// Images are different, so produce some debug info
final String testResultsPath = isCirrus
? p.join(
Platform.environment['CIRRUS_WORKING_DIR'],
'test_results',
)
: p.join(
env.environment.webUiDartToolDir.path,
'test_results',
);
Directory(testResultsPath).createSync(recursive: true);
final String testResultsPath =
env.environment.webUiTestResultsDirectory.path;
final String basename = p.basenameWithoutExtension(file.path);
final File actualFile =

View File

@@ -170,12 +170,7 @@ class TestCommand extends Command<bool> with ArgUtils {
await _runPubGet();
}
// In order to run iOS Safari unit tests we need to make sure iOS Simulator
// is booted.
if (isSafariIOS) {
await IosSafariArgParser.instance.initIosSimulator();
}
await _prepare();
await _buildTargets();
if (runAllTests) {
@@ -186,6 +181,21 @@ class TestCommand extends Command<bool> with ArgUtils {
return true;
}
/// Preparations before running the tests such as booting simulators or
/// creating directories.
Future<void> _prepare() async {
if (environment.webUiTestResultsDirectory.existsSync()) {
environment.webUiTestResultsDirectory.deleteSync(recursive: true);
}
environment.webUiTestResultsDirectory.createSync(recursive: true);
// In order to run iOS Safari unit tests we need to make sure iOS Simulator
// is booted.
if (isSafariIOS) {
await IosSafariArgParser.instance.initIosSimulator();
}
}
/// Builds all test targets that will be run.
Future<void> _buildTargets() async {
final Stopwatch stopwatch = Stopwatch()..start();