Skip to content

Commit c66f91b

Browse files
fishythefishCommit Queue
authored andcommitted
[dynamic_modules] Update pubspec to 3.8 and reformat.
Change-Id: I7cdfb0000996a711bdee9b1618c20a21bbdda814 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/427620 Commit-Queue: Nate Biggs <[email protected]> Reviewed-by: Nate Biggs <[email protected]> Auto-Submit: Mayank Patke <[email protected]>
1 parent d6209f2 commit c66f91b

File tree

11 files changed

+264
-156
lines changed

11 files changed

+264
-156
lines changed

pkg/dynamic_modules/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: dynamic_modules
33
publish_to: none
44

55
environment:
6-
sdk: ^3.5.0
6+
sdk: ^3.8.0
77

88
resolution: workspace
99

pkg/dynamic_modules/test/common/testing.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ import 'read_bytes.dart' if (dart.library.io) 'read_bytes_aot.dart';
1919
///
2020
/// Optional [transformBytes] callback can be used to tweak dynamic modules
2121
/// bytes if underlying implementation loads dynamic modules from bytes.
22-
Future<Object?> load(String moduleName,
23-
{Uint8List Function(Uint8List)? transformBytes}) {
22+
Future<Object?> load(
23+
String moduleName, {
24+
Uint8List Function(Uint8List)? transformBytes,
25+
}) {
2426
if (const bool.fromEnvironment('dart.library.html')) {
2527
// DDC implementation
2628
return loadModuleFromUri(Uri(scheme: '', path: moduleName));

pkg/dynamic_modules/test/data/enum/modules/entry1.dart

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
enum Foo {
6-
e1,
7-
e2,
8-
e3;
9-
}
5+
enum Foo { e1, e2, e3 }
106

117
@pragma('dyn-module:entry-point')
128
Object? dynamicModuleEntrypoint() => Foo.e2;

pkg/dynamic_modules/test/data/load_unmodifiable_view/main.dart

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ import 'package:expect/expect.dart';
99

1010
/// Dynamic module can be loaded from unmodifiable view.
1111
void main() async {
12-
final result = await helper.load('entry1.dart',
13-
transformBytes: (Uint8List bytes) => bytes.buffer
14-
.asUint8List(0, bytes.lengthInBytes)
15-
.asUnmodifiableView());
12+
final result = await helper.load(
13+
'entry1.dart',
14+
transformBytes: (Uint8List bytes) =>
15+
bytes.buffer.asUint8List(0, bytes.lengthInBytes).asUnmodifiableView(),
16+
);
1617
Expect.equals(42, result);
1718
helper.done();
1819
}

pkg/dynamic_modules/test/runner/dart2wasm.dart

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,11 @@ class Dart2wasmExecutor implements TargetExecutor {
5656
}
5757

5858
Future _compile(
59-
String testName, String source, Uri sourceDir, bool isMain) async {
59+
String testName,
60+
String source,
61+
Uri sourceDir,
62+
bool isMain,
63+
) async {
6064
var testDir = _tmp.uri.resolve(testName).toFilePath();
6165
var args = [
6266
'--packages=${repoRoot.toFilePath()}/.dart_tool/package_config.json',
@@ -72,8 +76,13 @@ class Dart2wasmExecutor implements TargetExecutor {
7276
'$rootScheme:/data/$testName/$source',
7377
'$source.wasm',
7478
];
75-
await runProcess(compileBenchmark.toFilePath(), args, testDir, _logger,
76-
'compile $testName/$source');
79+
await runProcess(
80+
compileBenchmark.toFilePath(),
81+
args,
82+
testDir,
83+
_logger,
84+
'compile $testName/$source',
85+
);
7786
}
7887

7988
@override
@@ -100,16 +109,19 @@ class Dart2wasmExecutor implements TargetExecutor {
100109
// module), and finally launches the app.
101110
var testDir = _tmp.uri.resolve('${test.name}/');
102111
var result = await runProcess(
103-
runBenchmark.toFilePath(),
104-
['${test.main}.wasm'],
105-
testDir.toFilePath(),
106-
_logger,
107-
'run_benchmark ${test.main}.wasm');
112+
runBenchmark.toFilePath(),
113+
['${test.main}.wasm'],
114+
testDir.toFilePath(),
115+
_logger,
116+
'run_benchmark ${test.main}.wasm',
117+
);
108118
var stdout = result.stdout as String;
109119
if (!stdout.contains(helper.successToken)) {
110-
_logger.error('Error: test didn\'t complete as expected.\n'
111-
'Make sure the test finishes and calls `helper.done()`.\n'
112-
'Test output:\n$stdout');
120+
_logger.error(
121+
'Error: test didn\'t complete as expected.\n'
122+
'Make sure the test finishes and calls `helper.done()`.\n'
123+
'Test output:\n$stdout',
124+
);
113125
throw Exception('missing helper.done');
114126
}
115127
}

pkg/dynamic_modules/test/runner/ddc.dart

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,11 @@ class DdcExecutor implements TargetExecutor {
5959

6060
// TODO(sigmund): add support to run also in the ddc-canary mode.
6161
Future _compile(
62-
String testName, String source, Uri sourceDir, bool isMain) async {
62+
String testName,
63+
String source,
64+
Uri sourceDir,
65+
bool isMain,
66+
) async {
6367
var testDir = _tmp.uri.resolve(testName).toFilePath();
6468
var args = [
6569
'--packages=${repoRoot.toFilePath()}/.dart_tool/package_config.json',
@@ -85,12 +89,20 @@ class DdcExecutor implements TargetExecutor {
8589
'-o',
8690
'$source.js',
8791
];
88-
await runProcess(dartAotBin.toFilePath(), args, testDir, _logger,
89-
'compile $testName/$source');
92+
await runProcess(
93+
dartAotBin.toFilePath(),
94+
args,
95+
testDir,
96+
_logger,
97+
'compile $testName/$source',
98+
);
9099
}
91100

92101
Future _buildKernelOutline(
93-
String testName, String source, Uri sourceDir) async {
102+
String testName,
103+
String source,
104+
Uri sourceDir,
105+
) async {
94106
assert(source == 'main.dart');
95107
var testDir = _tmp.uri.resolve(testName).toFilePath();
96108
var args = [
@@ -112,8 +124,13 @@ class DdcExecutor implements TargetExecutor {
112124
'$source.dill',
113125
];
114126

115-
await runProcess(dartAotBin.toFilePath(), args, testDir, _logger,
116-
'sumarize $testName/$source');
127+
await runProcess(
128+
dartAotBin.toFilePath(),
129+
args,
130+
testDir,
131+
_logger,
132+
'sumarize $testName/$source',
133+
);
117134
}
118135

119136
@override
@@ -172,16 +189,19 @@ class DdcExecutor implements TargetExecutor {
172189
});
173190
''');
174191
var result = await runProcess(
175-
d8Uri.toFilePath(),
176-
[bootstrapUri.toFilePath()],
177-
testDir.toFilePath(),
178-
_logger,
179-
'd8 ${test.name}/bootstrap.js');
192+
d8Uri.toFilePath(),
193+
[bootstrapUri.toFilePath()],
194+
testDir.toFilePath(),
195+
_logger,
196+
'd8 ${test.name}/bootstrap.js',
197+
);
180198
var stdout = result.stdout as String;
181199
if (!stdout.contains(helper.successToken)) {
182-
_logger.error('Error: test didn\'t complete as expected.\n'
183-
'Make sure the test finishes and calls `helper.done()`.\n'
184-
'Test output:\n$stdout');
200+
_logger.error(
201+
'Error: test didn\'t complete as expected.\n'
202+
'Make sure the test finishes and calls `helper.done()`.\n'
203+
'Test output:\n$stdout',
204+
);
185205
throw Exception('missing helper.done');
186206
}
187207
}

pkg/dynamic_modules/test/runner/main.dart

Lines changed: 46 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,34 @@ void main(List<String> args) async {
2222
var tests = loadAllTests(suiteRoot);
2323
final parser = ArgParser()
2424
..addFlag('help', help: 'Help message', negatable: false, abbr: 'h')
25-
..addOption('test',
26-
help: 'Run a single test, rather than the entire suite',
27-
allowed: tests.map((t) => t.name).toList(),
28-
abbr: 't')
29-
..addOption('runtime',
30-
help: 'Which runtime to use to run the test configuration',
31-
allowed: Target.values.map((v) => v.name),
32-
defaultsTo: Target.ddc.name,
33-
abbr: 'r')
34-
..addOption('configuration',
35-
help: 'Configuration to use for reporting test results', abbr: 'n')
36-
..addOption('output-directory',
37-
help: 'location where to emit the json-l result and log files')
38-
..addFlag('verbose',
39-
help: 'Show a lot of information', negatable: false, abbr: 'v');
25+
..addOption(
26+
'test',
27+
help: 'Run a single test, rather than the entire suite',
28+
allowed: tests.map((t) => t.name).toList(),
29+
abbr: 't',
30+
)
31+
..addOption(
32+
'runtime',
33+
help: 'Which runtime to use to run the test configuration',
34+
allowed: Target.values.map((v) => v.name),
35+
defaultsTo: Target.ddc.name,
36+
abbr: 'r',
37+
)
38+
..addOption(
39+
'configuration',
40+
help: 'Configuration to use for reporting test results',
41+
abbr: 'n',
42+
)
43+
..addOption(
44+
'output-directory',
45+
help: 'location where to emit the json-l result and log files',
46+
)
47+
..addFlag(
48+
'verbose',
49+
help: 'Show a lot of information',
50+
negatable: false,
51+
abbr: 'v',
52+
);
4053
final options = parser.parse(args);
4154
if (options['help'] as bool) {
4255
print(parser.usage);
@@ -68,10 +81,12 @@ void main(List<String> args) async {
6881
}
6982
results.add(testResult);
7083
}
71-
final result = _reportResults(results,
72-
writeLog: singleTest == null,
73-
configuration: options['configuration'],
74-
logDir: options['output-directory']);
84+
final result = _reportResults(
85+
results,
86+
writeLog: singleTest == null,
87+
configuration: options['configuration'],
88+
logDir: options['output-directory'],
89+
);
7590
if (result != 0) {
7691
exitCode = result;
7792
}
@@ -83,7 +98,9 @@ void main(List<String> args) async {
8398
/// Takes the steps to build the artifacts needed by a test and then execute it
8499
/// on the target environment.
85100
Future<DynamicModuleTestResult> _runSingleTest(
86-
DynamicModuleTest test, TargetExecutor target) async {
101+
DynamicModuleTest test,
102+
TargetExecutor target,
103+
) async {
87104
var timer = Stopwatch()..start();
88105
try {
89106
await target.compileApplication(test);
@@ -132,14 +149,16 @@ int _reportResults(
132149
// Ensure the directory URI ends with a path separator.
133150
var dirUri = Directory(logDir).uri;
134151
File.fromUri(dirUri.resolve('results.json')).writeAsStringSync(
135-
results.map((r) => '${r.toRecordJson(configuration)}\n').join(),
136-
flush: true);
152+
results.map((r) => '${r.toRecordJson(configuration)}\n').join(),
153+
flush: true,
154+
);
137155
File.fromUri(dirUri.resolve('logs.json')).writeAsStringSync(
138-
results
139-
.where((r) => r.status != Status.pass)
140-
.map((r) => '${r.toLogJson(configuration)}\n')
141-
.join(),
142-
flush: true);
156+
results
157+
.where((r) => r.status != Status.pass)
158+
.map((r) => '${r.toLogJson(configuration)}\n')
159+
.join(),
160+
flush: true,
161+
);
143162

144163
print('Success: log files emitted under $dirUri');
145164
} else if (fail) {

pkg/dynamic_modules/test/runner/model.dart

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,12 @@ class DynamicModuleTest {
2424
final Map<String, String> dynamicModules;
2525

2626
DynamicModuleTest(
27-
this.name, this.folder, this.main, this.interface, this.dynamicModules);
27+
this.name,
28+
this.folder,
29+
this.main,
30+
this.interface,
31+
this.dynamicModules,
32+
);
2833
}
2934

3035
/// Result of an individual module test.
@@ -40,13 +45,21 @@ class DynamicModuleTestResult {
4045
DynamicModuleTestResult._(test.name, Status.pass, '', time);
4146

4247
factory DynamicModuleTestResult.compileError(
43-
DynamicModuleTest test, String details, Duration time) =>
44-
DynamicModuleTestResult._(
45-
test.name, Status.compileTimeError, details, time);
48+
DynamicModuleTest test,
49+
String details,
50+
Duration time,
51+
) => DynamicModuleTestResult._(
52+
test.name,
53+
Status.compileTimeError,
54+
details,
55+
time,
56+
);
4657

4758
factory DynamicModuleTestResult.runtimeError(
48-
DynamicModuleTest test, String details, Duration time) =>
49-
DynamicModuleTestResult._(test.name, Status.runtimeError, details, time);
59+
DynamicModuleTest test,
60+
String details,
61+
Duration time,
62+
) => DynamicModuleTestResult._(test.name, Status.runtimeError, details, time);
5063

5164
/// Emit the result in the JSON format expected by the test infrastructure.
5265
String toRecordJson(String configuration) {

pkg/dynamic_modules/test/runner/target.dart

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,7 @@ library;
99
import 'model.dart';
1010

1111
/// Possible backends where the tests can be executed.
12-
enum Target {
13-
aot,
14-
jit,
15-
dart2wasm,
16-
ddc,
17-
}
12+
enum Target { aot, jit, dart2wasm, ddc }
1813

1914
/// Defines how to build and run a test in a specific target.
2015
///

0 commit comments

Comments
 (0)