Skip to content

Enable weak tests for build daemon and frontend server #1824

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Dec 14, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions dwds/test/fixtures/context.dart
Original file line number Diff line number Diff line change
@@ -229,6 +229,7 @@ class TestContext {
String basePath = '';

_port = await findUnusedPort();
final soundNullSafety = nullSafety == NullSafety.sound;
switch (compilationMode) {
case CompilationMode.buildDaemon:
{
@@ -237,6 +238,8 @@ class TestContext {
'--define',
'build_web_compilers|ddc=generate-full-dill=true',
],
'--define',
'build_web_compilers:entrypoint=sound_null_safety=$soundNullSafety',
'--verbose',
];
_daemonClient =
10 changes: 0 additions & 10 deletions dwds/test/utils/version_compatibility.dart
Original file line number Diff line number Diff line change
@@ -2,21 +2,11 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'dart:io';

import 'package:pub_semver/pub_semver.dart';

import '../fixtures/context.dart';

bool supportedMode(
{required CompilationMode compilationMode,
required NullSafety nullSafetyMode}) {
final isDart3 = Version.parse(Platform.version.split(' ')[0]).major == 3;
// TODO(https://github.com/dart-lang/webdev/issues/1818): Support compiling to
// to weak null-safety for both FrontendServer and BuildDaemon.
if (isDart3 && nullSafetyMode == NullSafety.weak) {
return false;
}
// TODO(https://github.com/dart-lang/webdev/issues/1591): Support compiling to
// sound null-safety for the FrontendServer.
if (compilationMode == CompilationMode.frontendServer &&
2 changes: 2 additions & 0 deletions fixtures/_test/example/append_body/main.dart
Original file line number Diff line number Diff line change
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

// @dart=2.9

import 'dart:async';
import 'dart:developer';
import 'dart:html';
2 changes: 2 additions & 0 deletions fixtures/_test/example/hello_world/main.dart
Original file line number Diff line number Diff line change
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

// @dart=2.9

import 'dart:async';
import 'dart:convert';
import 'dart:developer';
2 changes: 2 additions & 0 deletions fixtures/_test/example/hello_world/part.dart
Original file line number Diff line number Diff line change
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

// @dart=2.9

part of 'main.dart';

var blah = 'blah';
8 changes: 4 additions & 4 deletions fixtures/_test/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -9,12 +9,12 @@ description: >-
publish_to: none

environment:
sdk: ">=2.5.0 <3.0.0"
sdk: ">=2.18.0 <3.0.0"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically this is what makes the weak tests work. Filed an issue to investigate why this constraint solves at all: https://github.com/dart-lang/sdk/issues/50717

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently it is a feature (reply from the issue above) so the solution is confirmed:

(I believe <3.0.0 is treated the same as <4.0.0 when the lower bound is >= 2.12.0 (dart-lang/pana@9882d0e).
The cause of this resolution failure is because a lower bound below 2.12, in this case >=2.10.0, means that package does not support null safety which is required by Dart 3. See dart-lang/pub#3686 for more context on the resolution message.


dependencies:
intl: ^0.16.0
intl: ^0.17.0
path: ^1.6.1

dev_dependencies:
build_runner: ^2.0.0
build_web_compilers: ^3.0.0
build_runner: '>=1.6.2 <3.0.0'
build_web_compilers: '>=2.12.0 <4.0.0'
6 changes: 3 additions & 3 deletions fixtures/_testCircular1/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -5,14 +5,14 @@
name: _test_circular1
version: 1.0.0
description: >-
A fake package used for testing weak null-safety.
A fake package used for testing weak null-safety with circular dependency.
publish_to: none

environment:
sdk: ">=2.5.0 <3.0.0"
sdk: ">=2.18.0 <3.0.0"

dependencies:
intl: ^0.16.0
intl: ^0.17.0
path: ^1.6.1
_test_circular2:
path: ../_testCircular2
4 changes: 2 additions & 2 deletions fixtures/_testCircular1Sound/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: _test_circular1_sound
version: 1.0.0
description: >-
A fake package used for testing sound null-safety.
A fake package used for testing imports with sound null-safety with circular dependency.
publish_to: none

environment:
sdk: '>=2.12.0 <3.0.0'
sdk: '>=2.18.0 <3.0.0'

dependencies:
intl: ^0.17.0
4 changes: 2 additions & 2 deletions fixtures/_testCircular2/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -5,11 +5,11 @@
name: _test_circular2
version: 1.0.0
description: >-
A fake package used for testing imports with weak null-safety. Imports _test.
A fake package used for testing imports with weak null-safety with circular dependency.
publish_to: none

environment:
sdk: ">=2.10.0 <3.0.0"
sdk: ">=2.18.0 <3.0.0"

dependencies:
_test_circular1:
4 changes: 2 additions & 2 deletions fixtures/_testCircular2Sound/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: _test_circular2_sound
version: 1.0.0
description: >-
A fake package used for testing imports with sound null-safety. Imports _test.
A fake package used for testing imports with sound null-safety with circular dependency.
publish_to: none

environment:
sdk: '>=2.12.0 <3.0.0'
sdk: '>=2.18.0 <3.0.0'

dependencies:
_test_circular1_sound:
2 changes: 1 addition & 1 deletion fixtures/_testPackage/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ description: >-
publish_to: none

environment:
sdk: ">=2.10.0 <3.0.0"
sdk: ">=2.18.0 <3.0.0"

dependencies:
_test:
4 changes: 4 additions & 0 deletions frontend_server_common/lib/src/frontend_server_client.dart
Original file line number Diff line number Diff line change
@@ -259,6 +259,7 @@ class ResidentCompiler {
required this.fileSystemRoots,
required this.fileSystemScheme,
required this.platformDill,
required this.soundNullSafety,
this.verbose = false,
CompilerMessageConsumer compilerMessageConsumer = defaultConsumer,
}) : _stdoutHandler = StdoutHandler(consumer: compilerMessageConsumer);
@@ -269,6 +270,7 @@ class ResidentCompiler {
final List<Uri> fileSystemRoots;
final String fileSystemScheme;
final String platformDill;
final bool soundNullSafety;
final bool verbose;

/// The path to the root of the Dart SDK used to compile.
@@ -386,6 +388,8 @@ class ResidentCompiler {
],
if (useDebuggerModuleNames) '--debugger-module-names',
'--experimental-emit-debug-metadata',
if (soundNullSafety) '--sound-null-safety',
if (!soundNullSafety) '--no-sound-null-safety',
if (verbose) '--verbose'
];

1 change: 1 addition & 0 deletions frontend_server_common/lib/src/resident_runner.dart
Original file line number Diff line number Diff line change
@@ -46,6 +46,7 @@ class ResidentWebRunner {
fileSystemRoots: fileSystemRoots,
fileSystemScheme: fileSystemScheme,
verbose: verbose,
soundNullSafety: soundNullSafety,
);
expressionCompiler = TestExpressionCompiler(generator);
}
1 change: 1 addition & 0 deletions webdev/test/e2e_test.dart
Original file line number Diff line number Diff line change
@@ -302,6 +302,7 @@ void main() {
'daemon',
'web:$openPort',
'--enable-expression-evaluation',
'--null-safety=$nullSafetyOption',
'--verbose',
];
var process = await runWebDev(args,