1
0
mirror of https://github.com/dart-lang/sdk synced 2024-07-08 20:16:39 +00:00

[ddc] Add configuration to compile with asserts

- Assertions are enabled in the compiler itself. DDC already enables
  assertions in the test code by default. 
- Runs tests in d8.

Change-Id: Ibdf285d9ab182c3859f4724b4c0740579d6d2377
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/349361
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: William Hesse <whesse@google.com>
This commit is contained in:
Nicholas Shahan 2024-04-04 14:40:30 +00:00 committed by Commit Queue
parent 671f271f58
commit 5532568778
7 changed files with 81 additions and 5 deletions

View File

@ -19,6 +19,9 @@ void main() {
"enable-asserts": true
},
},
"ddc-hostasserts-linux-d8": {
"options": {"host-asserts": true, "use-sdk": false}
},
},
"builder_configurations": [],
});
@ -33,6 +36,11 @@ void main() {
equals(Configuration("x64-ddc-vm-linux", Architecture.x64,
Compiler.ddc, Mode.release, Runtime.vm, System.linux,
enableAsserts: true)));
expect(
testMatrix.configurations[2],
equals(Configuration("ddc-hostasserts-linux-d8", Architecture.x64,
Compiler.ddc, Mode.release, Runtime.d8, System.linux,
enableHostAsserts: true)));
});
test("error if expanded configuration names collide", () {

View File

@ -328,6 +328,8 @@ class Dart2jsCompilationCommand extends CompilationCommand {
class DevCompilerCompilationCommand extends CompilationCommand {
final String compilerPath;
final bool enableHostAsserts;
DevCompilerCompilationCommand(
String outputFile,
List<Uri> bootstrapDependencies,
@ -336,6 +338,7 @@ class DevCompilerCompilationCommand extends CompilationCommand {
Map<String, String> environmentOverrides,
{required this.compilerPath,
required bool alwaysCompile,
required this.enableHostAsserts,
String? workingDirectory,
int index = 0})
: super("ddc", outputFile, bootstrapDependencies, executable, arguments,
@ -350,6 +353,7 @@ class DevCompilerCompilationCommand extends CompilationCommand {
executable, arguments, environmentOverrides,
compilerPath: compilerPath,
alwaysCompile: _alwaysCompile,
enableHostAsserts: enableHostAsserts,
workingDirectory: workingDirectory,
index: index);
@ -364,6 +368,7 @@ class DevCompilerCompilationCommand extends CompilationCommand {
@override
List<String> get batchArguments {
return <String>[
if (enableHostAsserts) '--enable-asserts',
compilerPath,
...super.batchArguments,
];
@ -372,6 +377,7 @@ class DevCompilerCompilationCommand extends CompilationCommand {
@override
List<String> get nonBatchArguments {
return <String>[
if (enableHostAsserts) '--enable-asserts',
compilerPath,
...super.nonBatchArguments,
];

View File

@ -649,6 +649,13 @@ class DevCompilerConfiguration extends CompilerConfiguration {
@override
String computeCompilerPath() {
if (_enableHostAsserts && _useSdk) {
// When [_useSdk] is true, ddc is compiled into a snapshot that was
// built without assertions enabled. The VM cannot make such snapshot run
// with assertions later. These two flags could be used together if we
// also build sdk snapshots with assertions enabled.
throw "--host-asserts and --use-sdk cannot be used together";
}
// DDC is a Dart program and not an executable itself, so the command to
// spawn as a subprocess is a Dart VM.
// Internally the [DevCompilerCompilationCommand] will prepend the snapshot
@ -734,12 +741,14 @@ class DevCompilerConfiguration extends CompilerConfiguration {
args.add("$summary=$package");
}
var compilerPath = _useSdk
var compilerPath = _useSdk && !_enableHostAsserts
? '${_configuration.buildDirectory}/dart-sdk/bin/snapshots/dartdevc.dart.snapshot'
: Repository.uri.resolve('pkg/dev_compiler/bin/dartdevc.dart').path;
var command = DevCompilerCompilationCommand(outputFile,
bootstrapDependencies(), computeCompilerPath(), args, environment,
compilerPath: compilerPath, alwaysCompile: false);
compilerPath: compilerPath,
alwaysCompile: false,
enableHostAsserts: _enableHostAsserts);
if (_configuration.rr) {
return RRCommand(command);
}
@ -784,11 +793,16 @@ class DevCompilerConfiguration extends CompilerConfiguration {
var pkgJsDir = Uri.directory(_configuration.buildDirectory)
.resolve('$buildOptionsDir/pkg/ddc');
var sdkJsPath = 'dart_sdk.js';
// Approximate the renaming done to identifiers in `pathToJSIdentifier()`
// from pkg/dev_compiler/lib/src/compiler/js_names.dart to handle the
// invalid library names from test files encountered so far.
var libraryName = inputUri.path
.substring(repositoryUri.path.length)
.replaceAll("/", "__")
.replaceAll("-", "_")
.replaceAll(".dart", "");
.replaceAll('/', '__')
.replaceAll('-', '_')
.replaceAll('.dart', '')
.replaceAllMapped(RegExp(r'[^A-Za-z_$0-9]'),
(Match m) => '\$${m[0]!.codeUnits.join('')}');
var testPackageLoadStatements = [
for (var package in testPackages) 'load("$pkgJsDir/$package.js");'
].join('\n');

View File

@ -99,3 +99,6 @@ LibTest/typed_data/Uint64List/*: SkipByDesign # Uint64List not supported on the
[ $compiler == ddc && $runtime == chrome ]
LibTest/html/Window/animationFrame_A01_t01: SkipByDesign # Issue #53985: requestAnimationFrame is not executed on Chrome inactive tabs
[ $compiler == ddc && $runtime == d8 ]
LibTest/html/*: SkipByDesign # Browser tests

View File

@ -34,6 +34,9 @@ html/js_dispatch_property_test: Skip # Timeout Issue 31030
html/request_animation_frame_test: SkipByDesign # Issue #53985: requestAnimationFrame is not executed on Chrome inactive tabs
html/transition_event_test: SkipByDesign # Issue #53985: css transitions are not executed on Chrome inactive tabs
[ $compiler == ddc && $runtime == d8 ]
html/*: SkipByDesign # Browser tests
[ $compiler == ddc && $runtime == ff ]
html/mediadevices_test: SkipByDesign # Not supported on FF, likely requires user-interaction that causes timeout

View File

@ -15,6 +15,7 @@ wasm/*: SkipByDesign
[ $compiler == ddc ]
async_stacktrace_test: Skip # Issue 53555
native/*: Skip # dart2js tests for native keyword
[ $runtime == jsshell ]
deferred/load_in_correct_order_test: SkipByDesign # jsshell preamble does not support this test.

View File

@ -47,6 +47,8 @@
"out/ReleaseX64/dart",
"out/ReleaseX64/dart2js_platform.dill",
"out/ReleaseX64/dart2js_platform_unsound.dill",
"out/ReleaseX64/ddc_outline.dill",
"out/ReleaseX64/gen/utils/ddc/",
"pkg/",
"runtime/tests/",
"sdk/",
@ -608,6 +610,13 @@
"use-sdk": true
}
},
"ddc-hostasserts-linux-d8": {
"options": {
"checked": true,
"host-asserts": true,
"use-sdk": false
}
},
"cfe-weak-(linux|mac|win)": {
"options": {
"compiler": "fasta"
@ -2091,6 +2100,38 @@
}
]
},
{
"builders": [
"ddc-hostasserts-linux-d8"
],
"meta": {
"description": "DDC with assertions during compilation running in d8"
},
"steps": [
{
"name": "build dart",
"script": "tools/build.py",
"arguments": [
"dart2js_bot",
"ddc_stable_test"
]
},
{
"name": "ddc sdk tests",
"arguments": [
"-nddc-hostasserts-linux-d8",
"co19",
"corelib",
"dartdevc",
"language",
"lib",
"web"
],
"shards": 12,
"fileset": "js_platform_hostasserts"
}
]
},
{
"builders": [
"vm-eager-optimization-linux-release-ia32",