Commit c2813693 authored by Kate Lovett's avatar Kate Lovett Committed by Flutter GitHub Bot

Fix subdirectory output (#47256)

parent f05ab503
......@@ -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
......
......@@ -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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment