Skip to content

Running flutter test --update-goldens with an integration test causes FileSystemException #143299

@tbuczkowski

Description

@tbuczkowski

Steps to reproduce

  1. Add the integration_test package to the project and create an integration test.
  2. Add an expectLater with matchesGoldenFile('some_file.png') somewhere in the test.
  3. Run flutter test <path to the test> --update-goldens on an Android Emulator (I didn't test on iOS)
  4. The integration test will run normally but will throw FileSystemException after finishing and produce no screenshots.

Expected results

Images for the golden tests should be created and the test run should not throw any exceptions.

If I run the same test but as a widget test instead of integration test, the images get created correctly, but then there's the limitation of not being able to access any native APIs in the test, since it's not being run on a device/emulator.

Since matchesGoldenFile docs don't mention anything about it not working in an integration test environment, I'd presume it should work the same way in widget and integration tests.

Actual results

══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════
The following FileSystemException was thrown while running async test code:
Creation failed, path = '/Users' (OS Error: Read-only file system, errno = 30)

When the exception was thrown, this was the stack:
#0      _checkForErrorResponse (dart:io/common.dart:55:9)
#1      _Directory.create.<anonymous closure> (dart:io/directory_impl.dart:114:9)
<asynchronous suspension>
#7      _Directory.create.<anonymous closure>.<anonymous closure> (dart:io/directory_impl.dart:104:54)
<asynchronous suspension>
#8      _Directory.create.<anonymous closure>.<anonymous closure> (dart:io/directory_impl.dart:104:54)
<asynchronous suspension>
#9      _Directory.create.<anonymous closure>.<anonymous closure> (dart:io/directory_impl.dart:104:54)
<asynchronous suspension>
#10     _Directory.create.<anonymous closure>.<anonymous closure> (dart:io/directory_impl.dart:104:54)
<asynchronous suspension>
#11     _Directory.create.<anonymous closure>.<anonymous closure> (dart:io/directory_impl.dart:104:54)
<asynchronous suspension>
#12     _Directory.create.<anonymous closure>.<anonymous closure> (dart:io/directory_impl.dart:104:54)
<asynchronous suspension>
#13     _Directory.create.<anonymous closure>.<anonymous closure> (dart:io/directory_impl.dart:104:54)
<asynchronous suspension>
#14     LocalFileComparator.update (package:flutter_test/src/_goldens_io.dart:109:5)
<asynchronous suspension>
#15     MatchesGoldenFile.matchAsync.<anonymous closure> (package:flutter_test/src/_matchers_io.dart:114:11)
<asynchronous suspension>
#16     LiveTestWidgetsFlutterBinding.runAsync (package:flutter_test/src/binding.dart:1990:14)
<asynchronous suspension>
#17     _expect.<anonymous closure> (package:matcher/src/expect/expect.dart:123:26)
<asynchronous suspension>
<asynchronous suspension>
#19     expectLater.<anonymous closure> (package:flutter_test/src/widget_tester.dart:496:24)
<asynchronous suspension>
#20     main.setBudgetAndQuantityAndGoToCheckout (file:///Users/<username>/<path to the project>/integration_test/guest_blind_order_checkout_flow_test.dart:233:5)
<asynchronous suspension>
#21     main.<anonymous closure> (file:///Users/<username>/<path to the project>/integration_test/guest_blind_order_checkout_flow_test.dart:349:5)
<asynchronous suspension>
#22     testWidgets.<anonymous closure>.<anonymous closure> (package:flutter_test/src/widget_tester.dart:168:15)
<asynchronous suspension>
#23     TestWidgetsFlutterBinding._runTestBody (package:flutter_test/src/binding.dart:1013:5)
<asynchronous suspension>
<asynchronous suspension>
(elided 7 frames from dart:async and package:stack_trace)
════════════════════════════════════════════════════════════════════════════════════════════════════

Test failed. See exception logs above.

Code sample

Code sample Any integration test containing `matchesGoldenFile` call.

Screenshots or Video

No response

Logs

No response

Flutter Doctor output

Doctor output
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.16.9, on macOS 14.2.1 23C71 darwin-arm64, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 15.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2023.1)
[✓] VS Code (version 1.86.0)
[✓] Connected device (5 available)
[✓] Network resources

• No issues found!

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work lista: tests"flutter test", flutter_test, or one of our testsf: integration_testThe flutter/packages/integration_test pluginfound in release: 3.16Found to occur in 3.16found in release: 3.20Found to occur in 3.20has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-androidAndroid applications specificallyteam-androidOwned by Android platform teamtriaged-androidTriaged by Android platform team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions