Fix subdirectory output (#47256)

This commit is contained in:
Kate Lovett
2019-12-18 16:33:01 -08:00
committed by Flutter GitHub Bot
parent f05ab50370
commit c281369356
2 changed files with 31 additions and 2 deletions

View File

@@ -155,7 +155,7 @@ class LocalComparisonOutput {
/// Returns the appropriate file for a given diff from a [ComparisonResult].
File getFailureFile(String failure, Uri golden, Uri basedir) {
final String fileName = golden.pathSegments[0];
final String fileName = golden.pathSegments.last;
final String testName = fileName.split(path.extension(fileName))[0]
+ '_'
+ failure

View File

@@ -149,7 +149,7 @@ void main() {
group('fails', () {
test('and generates correct output in the correct location', () async {
test('and generates correct output in the correct base location', () async {
comparator = LocalFileComparator(Uri.parse('local_test.dart'), pathStyle: fs.path.style);
await fs.file(fix('/golden.png')).writeAsBytes(_kColorFailurePngBytes);
try {
@@ -176,6 +176,35 @@ void main() {
}
});
test('and generates correct output when files are in a subdirectory', () async {
comparator = LocalFileComparator(Uri.parse('local_test.dart'), pathStyle: fs.path.style);
fs.file(fix('subdir/golden.png'))
..createSync(recursive:true)
..writeAsBytes(_kColorFailurePngBytes);
try {
await doComparison('subdir/golden.png');
fail('TestFailure expected but not thrown.');
} on TestFailure catch (error) {
expect(error.message, contains('% diff detected'));
final io.File master = fs.file(
fix('/failures/golden_masterImage.png')
);
final io.File test = fs.file(
fix('/failures/golden_testImage.png')
);
final io.File isolated = fs.file(
fix('/failures/golden_isolatedDiff.png')
);
final io.File masked = fs.file(
fix('/failures/golden_maskedDiff.png')
);
expect(master.existsSync(), isTrue);
expect(test.existsSync(), isTrue);
expect(isolated.existsSync(), isTrue);
expect(masked.existsSync(), isTrue);
}
});
test('when golden file does not exist', () async {
try {
await doComparison();