Skip to content

Commit

Permalink
Update tests to use the 2.12 null safety version (#3249)
Browse files Browse the repository at this point in the history
  • Loading branch information
jakemac53 committed Feb 28, 2022
1 parent 12de04f commit cfb5aec
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 33 deletions.
2 changes: 1 addition & 1 deletion build_runner/test/daemon/daemon_test.dart
Expand Up @@ -239,7 +239,7 @@ main() {
await d.dir('a', [
d.dir('web', [
d.file('main.dart', '''
// @dart=2.10
// @dart=2.12
main() {
print('goodbye world');
}'''),
Expand Down
2 changes: 2 additions & 0 deletions build_web_compilers/CHANGELOG.md
@@ -1,3 +1,5 @@
## 3.2.3-dev

## 3.2.2

- Allow the latest analyzer.
Expand Down
2 changes: 1 addition & 1 deletion build_web_compilers/pubspec.yaml
@@ -1,5 +1,5 @@
name: build_web_compilers
version: 3.2.2
version: 3.2.3-dev
description: Builder implementations wrapping Dart compilers.
repository: https://github.com/dart-lang/build/tree/master/build_web_compilers

Expand Down
59 changes: 28 additions & 31 deletions build_web_compilers/test/dart2js_bootstrap_test.dart
Expand Up @@ -4,7 +4,6 @@

import 'dart:async';

import 'package:build/experiments.dart';
import 'package:build_modules/build_modules.dart';
import 'package:build_test/build_test.dart';
import 'package:build_web_compilers/build_web_compilers.dart';
Expand Down Expand Up @@ -119,11 +118,11 @@ void main() {
test('sound null safety is defaulted based on the entrypoint', () async {
assets = {
'a|lib/is_sound.dart': '''
// @dart=2.10
// @dart=2.12
const unsoundMode = <int?>[] is List<int>;
''',
'a|web/sound.dart': '''
// @dart=2.10
// @dart=2.12
import 'package:a/is_sound.dart';
void main() {
print(unsoundMode);
Expand All @@ -138,34 +137,32 @@ void main() {
''',
};

await withEnabledExperiments(() async {
// Set up all the other required inputs for this test.
await testBuilderAndCollectAssets(const ModuleLibraryBuilder(), assets);
await testBuilderAndCollectAssets(MetaModuleBuilder(platform), assets);
await testBuilderAndCollectAssets(
MetaModuleCleanBuilder(platform), assets);
await testBuilderAndCollectAssets(ModuleBuilder(platform), assets);
// Check the inlined constant value for soundness
var expectedOutputs = {
'a|web/sound.dart.js': decodedMatches(allOf(
contains('NullSafetyMode.sound'),
isNot(contains('NullSafetyMode.unsound')))),
'a|web/sound.dart.js.map': anything,
'a|web/sound.dart.js.tar.gz': anything,
'a|web/unsound.dart.js': decodedMatches(allOf(
contains('NullSafetyMode.unsound'),
isNot(contains('NullSafetyMode.sound')))),
'a|web/unsound.dart.js.map': anything,
'a|web/unsound.dart.js.tar.gz': anything,
};
await testBuilder(
WebEntrypointBuilder(WebCompiler.Dart2Js,
soundNullSafetyOverride: null,
nullAssertions: false,
nativeNullAssertions: false),
assets,
outputs: expectedOutputs);
}, ['non-nullable']);
// Set up all the other required inputs for this test.
await testBuilderAndCollectAssets(const ModuleLibraryBuilder(), assets);
await testBuilderAndCollectAssets(MetaModuleBuilder(platform), assets);
await testBuilderAndCollectAssets(
MetaModuleCleanBuilder(platform), assets);
await testBuilderAndCollectAssets(ModuleBuilder(platform), assets);
// Check the inlined constant value for soundness
var expectedOutputs = {
'a|web/sound.dart.js': decodedMatches(allOf(
contains('NullSafetyMode.sound'),
isNot(contains('NullSafetyMode.unsound')))),
'a|web/sound.dart.js.map': anything,
'a|web/sound.dart.js.tar.gz': anything,
'a|web/unsound.dart.js': decodedMatches(allOf(
contains('NullSafetyMode.unsound'),
isNot(contains('NullSafetyMode.sound')))),
'a|web/unsound.dart.js.map': anything,
'a|web/unsound.dart.js.tar.gz': anything,
};
await testBuilder(
WebEntrypointBuilder(WebCompiler.Dart2Js,
soundNullSafetyOverride: null,
nullAssertions: false,
nativeNullAssertions: false),
assets,
outputs: expectedOutputs);
});
});
}

0 comments on commit cfb5aec

Please sign in to comment.