Skip to content

Commit 3797325

Browse files
authored
Fix Dart 3 dev CI builds (#3422)
* Fix build_web_compilers test fixture sdk constraints to allow dart 3.x. * add utility to check if unsound null safety is supported, use it to omit some tests * skip configurable uri test on windows CI * skip some of the null safety tests as well
1 parent cf0671c commit 3797325

File tree

10 files changed

+374
-108
lines changed

10 files changed

+374
-108
lines changed

.github/workflows/dart.yml

+297-69
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

_test/mono_pkg.yaml

+4-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ stages:
1010
- analyze: --fatal-infos .
1111
os: linux
1212
- unit_test:
13-
- group:
14-
- command: dart run build_runner test -- -p chrome --test-randomize-ordering-seed=random
15-
- command: dart run build_runner test -- -p vm test/configurable_uri_test.dart --test-randomize-ordering-seed=random
13+
- command: dart run build_runner test -- -p chrome --test-randomize-ordering-seed=random
14+
# TODO(https://github.com/dart-lang/build/issues/3423): restore this on windows
15+
- command: dart run build_runner test -- -p vm test/configurable_uri_test.dart --test-randomize-ordering-seed=random
16+
os: linux
1617
- e2e_test:
1718
- test: --total-shards 3 --shard-index 0 --test-randomize-ordering-seed=random
1819
os: linux

_test_common/lib/sdk.dart

+4
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,15 @@ import 'dart:io';
88
// ignore: implementation_imports
99
import 'package:build_runner_core/src/util/constants.dart';
1010
import 'package:path/path.dart' as p;
11+
import 'package:pub_semver/pub_semver.dart';
1112
import 'package:test/test.dart';
1213
import 'package:test_descriptor/test_descriptor.dart' as d;
1314

1415
String _dartBinary = p.join(sdkBin, 'dart');
1516

17+
final bool supportsUnsoundNullSafety =
18+
Version.parse(Platform.version.split(' ').first).major == 2;
19+
1620
/// Runs `pub get` on [package] (which is assumed to be in a directory with
1721
/// that name under the [d.sandbox] directory).
1822
Future<ProcessResult> pubGet(String package, {bool offline = true}) async {

_test_common/pubspec.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ dependencies:
1414
logging: ^1.0.0
1515
package_config: ^2.0.0
1616
path: ^1.8.0
17+
pub_semver: ^2.0.0
1718
test: ^1.16.0
1819
test_descriptor: ^2.0.0
1920
watcher: ^1.0.0

_test_null_safety/mono_pkg.yaml

+8-2
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,18 @@ stages:
1212
sdk: dev
1313
- e2e_test:
1414
- group:
15-
- command: dart run build_runner test -- -p chrome,vm --test-randomize-ordering-seed=random
15+
- command: dart run build_runner test -- -p chrome --test-randomize-ordering-seed=random
1616
- command: dart run build_runner test --define="build_web_compilers:entrypoint=compiler=dart2js" -- -p chrome --test-randomize-ordering-seed=random
17+
# TODO(https://github.com/dart-lang/build/issues/3423): restore this on windows
18+
- command: dart run build_runner test -- -p vm --test-randomize-ordering-seed=random
19+
os: linux
1720
# This stage is configured to only run for scheduled builds (see mono_repo.yaml)
1821
- e2e_test_cron:
1922
- group:
20-
- command: dart run build_runner test -- -p chrome,vm --test-randomize-ordering-seed=random
23+
- command: dart run build_runner test -- -p chrome --test-randomize-ordering-seed=random
2124
- command: dart run build_runner test --define="build_web_compilers:entrypoint=compiler=dart2js" -- -p chrome --test-randomize-ordering-seed=random
2225
sdk:
2326
- be/raw/latest
27+
# TODO(https://github.com/dart-lang/build/issues/3423): restore this on windows
28+
- command: dart run build_runner test -- -p vm --test-randomize-ordering-seed=random
29+
os: linux

build_runner/test/build_script_generate/build_script_generate_test.dart

+51-27
Original file line numberDiff line numberDiff line change
@@ -140,57 +140,69 @@ environment:
140140
buildYaml,
141141
d.dir('lib', [d.file('builder.dart', '')]),
142142
]).create();
143-
await runPub('a', 'get');
143+
var pubGetResult = await runPub('a', 'get');
144+
expect(pubGetResult.exitCode, 0,
145+
reason: 'stdout: ${pubGetResult.stdout}\n\n'
146+
'stderr: ${pubGetResult.stderr}');
144147

145148
final options = await findBuildScriptOptions(
146149
packageGraph: await PackageGraph.forPath('${d.sandbox}/a'));
147150
expect(options.canRunWithSoundNullSafety, isTrue);
148151
});
149152

150-
test('when the root package opts out', () async {
151-
await d.dir('a', [
152-
d.file('pubspec.yaml', '''
153+
if (supportsUnsoundNullSafety) {
154+
test('when the root package opts out', () async {
155+
await d.dir('a', [
156+
d.file('pubspec.yaml', '''
153157
name: a
154158
environment:
155159
sdk: '>=2.9.0 <3.0.0'
156160
'''),
157-
d.dir('lib', [d.file('builder.dart', '')]),
158-
]).create();
159-
await runPub('a', 'get');
161+
d.dir('lib', [d.file('builder.dart', '')]),
162+
]).create();
163+
var pubGetResult = await runPub('a', 'get');
164+
expect(pubGetResult.exitCode, 0,
165+
reason: 'stdout: ${pubGetResult.stdout}\n\n'
166+
'stderr: ${pubGetResult.stderr}');
160167

161-
final options = await findBuildScriptOptions(
162-
packageGraph: await PackageGraph.forPath('${d.sandbox}/a'));
163-
expect(options.canRunWithSoundNullSafety, isFalse);
164-
});
168+
final options = await findBuildScriptOptions(
169+
packageGraph: await PackageGraph.forPath('${d.sandbox}/a'));
170+
expect(options.canRunWithSoundNullSafety, isFalse);
171+
});
165172

166-
test('when a builder-defining package opts out', () async {
167-
await d.dir('a', [
168-
d.file('pubspec.yaml', '''
173+
test('when a builder-defining package opts out', () async {
174+
await d.dir('a', [
175+
d.file('pubspec.yaml', '''
169176
name: a
170177
environment:
171178
sdk: '>=2.12.0 <3.0.0'
172179
dependencies:
173180
b:
174181
path: ../b/
175182
'''),
176-
]).create();
177-
await d.dir('b', [
178-
d.file('pubspec.yaml', '''
183+
]).create();
184+
await d.dir('b', [
185+
d.file('pubspec.yaml', '''
179186
name: b
180187
environment:
181188
sdk: '>=2.9.0 <3.0.0'
182189
'''),
183-
buildYaml,
184-
d.dir('lib', [
185-
d.file('builder.dart', ''),
186-
]),
187-
]).create();
188-
await runPub('a', 'get');
190+
buildYaml,
191+
d.dir('lib', [
192+
d.file('builder.dart', ''),
193+
]),
194+
]).create();
195+
await runPub('a', 'get');
196+
var pubGetResult = await runPub('a', 'get');
197+
expect(pubGetResult.exitCode, 0,
198+
reason: 'stdout: ${pubGetResult.stdout}\n\n'
199+
'stderr: ${pubGetResult.stderr}');
189200

190-
final options = await findBuildScriptOptions(
191-
packageGraph: await PackageGraph.forPath('${d.sandbox}/a'));
192-
expect(options.canRunWithSoundNullSafety, isFalse);
193-
});
201+
final options = await findBuildScriptOptions(
202+
packageGraph: await PackageGraph.forPath('${d.sandbox}/a'));
203+
expect(options.canRunWithSoundNullSafety, isFalse);
204+
});
205+
}
194206

195207
test('when a builder-defining library ops out', () async {
196208
await d.dir('a', [
@@ -203,6 +215,10 @@ environment:
203215
d.dir('lib', [d.file('builder.dart', '// @dart=2.9')]),
204216
]).create();
205217
await runPub('a', 'get');
218+
var pubGetResult = await runPub('a', 'get');
219+
expect(pubGetResult.exitCode, 0,
220+
reason: 'stdout: ${pubGetResult.stdout}\n\n'
221+
'stderr: ${pubGetResult.stderr}');
206222

207223
final options = await findBuildScriptOptions(
208224
packageGraph: await PackageGraph.forPath('${d.sandbox}/a'));
@@ -227,6 +243,10 @@ builders:
227243
d.dir('tool', [d.file('builder.dart', '//@dart=2.9')]),
228244
]).create();
229245
await runPub('a', 'get');
246+
var pubGetResult = await runPub('a', 'get');
247+
expect(pubGetResult.exitCode, 0,
248+
reason: 'stdout: ${pubGetResult.stdout}\n\n'
249+
'stderr: ${pubGetResult.stderr}');
230250

231251
final options = await findBuildScriptOptions(
232252
packageGraph: await PackageGraph.forPath('${d.sandbox}/a'));
@@ -251,6 +271,10 @@ builders:
251271
d.dir('tool', [d.file('builder.dart', '')]),
252272
]).create();
253273
await runPub('a', 'get');
274+
var pubGetResult = await runPub('a', 'get');
275+
expect(pubGetResult.exitCode, 0,
276+
reason: 'stdout: ${pubGetResult.stdout}\n\n'
277+
'stderr: ${pubGetResult.stderr}');
254278

255279
final options = await findBuildScriptOptions(
256280
packageGraph: await PackageGraph.forPath('${d.sandbox}/a'));

build_vm_compilers/test/vm_kernel_integration_test.dart

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ import 'package:test/test.dart';
99
import 'package:test_descriptor/test_descriptor.dart' as d;
1010

1111
void main() {
12-
group('without null safety', () => _runTests(false));
12+
if (supportsUnsoundNullSafety) {
13+
group('without null safety', () => _runTests(false));
14+
}
1315
group('with null safety', () => _runTests(true));
1416
}
1517

build_web_compilers/test/fixtures/a/pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: a
22

33
environment:
4-
sdk: ">=1.0.0 <3.0.0"
4+
sdk: ">=1.0.0 <4.0.0"
55

66
dependencies:
77
b:

build_web_compilers/test/fixtures/b/pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: b
22

33
environment:
4-
sdk: ">=1.0.0 <3.0.0"
4+
sdk: ">=1.0.0 <4.0.0"
55

66
dependencies:
77
a:

tool/ci.sh

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)