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:
@@ -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(
|
||||
|
||||
@@ -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 =
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user