'flutter test' running on docker image causing testfile.dill.track.dill change and then causing test failure on CI environment

I'm having unit test erros running flutter test in a gitlab-ci environment. Below is a complete list of things I've already done trying to solve the issue, but haven't found a solution so far. I've opened an issue in github/flutter wondering if it might actually be a bug in flutter, but would be very glad to hear from you if any other suggestions are made. All logs are in GitHub issue, if needed in this question.

Steps to Reproduce

Due to proprietary reasons, I can't paste all my flutter code. I'll try to be as detailed as possible to help in the solution, and feel free to ask for more details.

The main objective is to have flutter test running on gitlab-ci, on a docker image. Therefore, I created a local docker image on my MacBook (Dockerfile is included below and was also pushed to Docker Hub) to reproduce and debug the failure.

  1. Run docker pull isorensen/flutter-ubuntu:1.12.13-stable
  2. Run docker run -v [flutter_project_root_directory]:/app -it --rm isorensen/flutter-ubuntu:1.12.13-stable
  3. Run flutter test on the Docker image. Run at least twice, since, as you'll see below, the first command might succeed and actually cause further tests to fail.

Expected results:

00:09 +14: All tests passed!

Actual results:

00:12 +0 -1: faq:  check if has values [E]                                                                                           
  type 'MappedListIterable<MapEntry<int, dynamic>, dynamic>' is not a subtype of type 'List<dynamic>' in type cast
  package:credifit/API/client.dart 307:80  ApiClient.getFaqs

00:12 +0 -2: faq:  check first default question [E]                                                                                  
  type 'MappedListIterable<MapEntry<int, dynamic>, dynamic>' is not a subtype of type 'List<dynamic>' in type cast
  package:credifit/API/client.dart 307:80  ApiClient.getFaqs

00:18 +10 -3: getUserLoanInfos [E]                                                                                                   
  Instance of 'Fatal'
  package:sdkgen_runtime/http_client.dart 30:5   SdkgenHttpClient._throwError
  package:sdkgen_runtime/http_client.dart 82:15  SdkgenHttpClient.makeRequest

00:19 +10 -4: simulateInstallments [E]                                                                                               
  type 'MappedListIterable<MapEntry<int, dynamic>, dynamic>' is not a subtype of type 'List<dynamic>' in type cast
  package:credifit/API/client.dart 313:236  ApiClient.simulateInstallments

00:19 +10 -4: Some tests failed.

What seems to be the problem

Since this problem does not occur on my local environment (running macOS Catalina, as detailed in logs below), what I noticed, running fswatch in my project folder and running flutter test in both environments (sharing the same project directory), only two files were "touched" (not necessarily changed):

  • .packages
  • .testfile.dill.track.dill

And after running diff on both files, before and after flutter test, noticed only testfile.dill.track.dill was changed.

Finally, when I did the sequence below, it made flutter test run successfully, concluding the error is being caused after a change in testfile.dill.track.dill cased by flutter test inside the docker image.

  1. Run flutter test on macOS (sharing the same project directory with docker image)
  2. Run cp build/testfile.dill.track.dill ~ to save a copy of the file
  3. Run flutter test on docker vm (the first time, the test runs successfully, but it alters test file.dill.track.dill)
  4. Run diff build/testfile.dill.track.dill ~/testfile.dill.track.dill

The result: Binary files build/testfile.dill.track.dill and /Users/eduardosorensen/testfile.dill.track.dill differ 5. Run flutter test on docker vm
The test above fails 6. Run cp ~/testfile.dill.track.dill build/testfile.dill.track.dill (to revert changed file) 7. Run flutter test on docker vm
The test above is successfully, although it changes again testfile.dill.track.dill and starts failing again on further tests