Skip to content

Commit 981f2ed

Browse files
Generator tests: prevent parallel running tests
1 parent dc72485 commit 981f2ed

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

.gitlab-ci.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,10 @@ generator-integ-tests:
8484
# Generator tests
8585
- cd generator
8686
- dart pub get
87-
- dart test
87+
# generator test suites must not run in parallel (see notes on GeneratorTestEnv):
88+
# Set concurrency=1 to run only one test suite (== test file) at a time.
89+
# Set --reporter expanded to print log for every completed test.
90+
- dart test --concurrency=1 --reporter expanded
8891
# ObjectBox tests
8992
- cd ../objectbox_test
9093
- ../install.sh

generator/test/generator_test_env.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ import 'package:test/test.dart';
1313
/// Helps testing the generator by running [EntityResolver] on the given
1414
/// [source] file and feeding the output directly into [CodeBuilder] and running
1515
/// it.
16+
///
17+
/// Warning: tests that use this or otherwise create files in the `lib` folder
18+
/// should not run in parallel as this might break when reading unexpected
19+
/// files from the `lib` source folder (see [run] which calls
20+
/// `TestReaderWriter.testing.loadIsolateSources()` and reads/deletes the model
21+
/// JSON file). So make sure tests are in the same test suite (`main()` method)
22+
/// and use `dart test --concurrency=1`.
23+
/// See also https://pub.dev/packages/test#test-concurrency.
1624
class GeneratorTestEnv {
1725
final EntityResolver resolver;
1826
final Config config;

0 commit comments

Comments
 (0)