Skip to content

Commit 1ee0894

Browse files
nshahanCommit Queue
authored andcommitted
[modular_test] Delete support for macro execution
Mostly a revert of https://dart-review.googlesource.com/c/sdk/+/361261. A straight revert contained merge conflicts that I resolved manually but I left some of the cleanup or refactoring in place. Change-Id: I2add9f4951d7c6c2399d8c95f36b1483279eea44 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/409401 Commit-Queue: Nicholas Shahan <[email protected]> Reviewed-by: Johnni Winther <[email protected]> Reviewed-by: Jake Macdonald <[email protected]>
1 parent ffe97e5 commit 1ee0894

File tree

16 files changed

+32
-288
lines changed

16 files changed

+32
-288
lines changed

pkg/compiler/tool/modular_test_suite.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import 'dart:async';
1111

1212
import 'package:modular_test/src/io_pipeline.dart';
1313
import 'package:modular_test/src/runner.dart';
14-
import 'package:modular_test/src/steps/macro_precompile_aot.dart';
1514
import 'modular_test_suite_helper.dart';
1615

1716
Future<void> main(List<String> args) async {
@@ -23,7 +22,6 @@ Future<void> main(List<String> args) async {
2322
'tests/modular',
2423
options,
2524
IOPipeline([
26-
PrecompileMacroAotStep(verbose: options.verbose),
2725
OutlineDillCompilationStep(),
2826
FullDillCompilationStep(),
2927
ConcatenateDillsStep(),

pkg/compiler/tool/modular_test_suite_helper.dart

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import 'package:modular_test/src/io_pipeline.dart';
2020
import 'package:modular_test/src/pipeline.dart';
2121
import 'package:modular_test/src/runner.dart';
2222
import 'package:modular_test/src/suite.dart';
23-
import 'package:modular_test/src/steps/macro_precompile_aot.dart';
2423
import 'package:modular_test/src/steps/util.dart';
2524
import 'package:path/path.dart' as p;
2625

@@ -157,11 +156,6 @@ abstract class CFEStep extends IOModularStep {
157156
...(transitiveDependencies.expand(
158157
(m) => ['--input-summary', '${toUri(m, inputData)}'],
159158
)),
160-
...transitiveDependencies
161-
.where((m) => m.macroConstructors.isNotEmpty)
162-
.expand(
163-
(m) => ['--precompiled-macro', '${precompiledMacroArg(m, toUri)};'],
164-
),
165159
...(sources.expand((String uri) => ['--source', uri])),
166160
...(flags.expand((String flag) => ['--enable-experiment', flag])),
167161
];
@@ -196,10 +190,7 @@ class OutlineDillCompilationStep extends CFEStep {
196190
bool get needsSources => true;
197191

198192
@override
199-
List<DataId> get dependencyDataNeeded => const [
200-
dillSummaryId,
201-
precompiledMacroId,
202-
];
193+
List<DataId> get dependencyDataNeeded => const [dillSummaryId];
203194

204195
@override
205196
List<DataId> get moduleDataNeeded => const [];
@@ -229,10 +220,7 @@ class FullDillCompilationStep extends CFEStep {
229220
bool get needsSources => true;
230221

231222
@override
232-
List<DataId> get dependencyDataNeeded => const [
233-
dillSummaryId,
234-
precompiledMacroId,
235-
];
223+
List<DataId> get dependencyDataNeeded => const [dillSummaryId];
236224

237225
@override
238226
List<DataId> get moduleDataNeeded => const [];

pkg/dev_compiler/lib/src/command/command.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,8 +335,7 @@ Future<CompilerResult> _compile(List<String> args,
335335
environmentDefines: declaredVariables,
336336
trackNeededDillLibraries: recordUsedInputs,
337337
nnbdMode:
338-
options.soundNullSafety ? fe.NnbdMode.Strong : fe.NnbdMode.Weak,
339-
precompiledMacros: options.precompiledMacros);
338+
options.soundNullSafety ? fe.NnbdMode.Strong : fe.NnbdMode.Weak);
340339
var incrementalCompiler = compilerState.incrementalCompiler!;
341340
var cachedSdkInput = compileSdk
342341
? null

pkg/dev_compiler/test/modular_helpers.dart

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import 'package:modular_test/src/create_package_config.dart';
99
import 'package:modular_test/src/io_pipeline.dart';
1010
import 'package:modular_test/src/pipeline.dart';
1111
import 'package:modular_test/src/runner.dart';
12-
import 'package:modular_test/src/steps/macro_precompile_aot.dart';
1312
import 'package:modular_test/src/steps/util.dart';
1413
import 'package:modular_test/src/suite.dart';
1514
import 'package:path/path.dart' as p;
@@ -34,7 +33,7 @@ class SourceToSummaryDillStep implements IOModularStep {
3433
bool get needsSources => true;
3534

3635
@override
37-
List<DataId> get dependencyDataNeeded => const [dillId, precompiledMacroId];
36+
List<DataId> get dependencyDataNeeded => const [dillId];
3837

3938
@override
4039
List<DataId> get moduleDataNeeded => const [];
@@ -108,10 +107,6 @@ class SourceToSummaryDillStep implements IOModularStep {
108107
...transitiveDependencies
109108
.where((m) => !m.isSdk)
110109
.expand((m) => ['--input-summary', '${toUri(m, dillId)}']),
111-
...transitiveDependencies
112-
.where((m) => m.macroConstructors.isNotEmpty)
113-
.expand((m) =>
114-
['--precompiled-macro', '${precompiledMacroArg(m, toUri)};']),
115110
...sources.expand((String uri) => ['--source', uri]),
116111
...flags.expand((String flag) => ['--enable-experiment', flag]),
117112
];
@@ -125,9 +120,6 @@ class SourceToSummaryDillStep implements IOModularStep {
125120
void notifyCached(Module module) {
126121
if (_options.verbose) print('\ncached step: source-to-dill on $module');
127122
}
128-
129-
@override
130-
bool shouldExecute(Module module) => true;
131123
}
132124

133125
class DDCStep implements IOModularStep {
@@ -142,7 +134,7 @@ class DDCStep implements IOModularStep {
142134
bool get needsSources => true;
143135

144136
@override
145-
List<DataId> get dependencyDataNeeded => const [dillId, precompiledMacroId];
137+
List<DataId> get dependencyDataNeeded => const [dillId];
146138

147139
@override
148140
List<DataId> get moduleDataNeeded => const [dillId];
@@ -206,10 +198,6 @@ class DDCStep implements IOModularStep {
206198
...transitiveDependencies
207199
.where((m) => !m.isSdk)
208200
.expand((m) => ['-s', '${toUri(m, dillId)}=${m.name}']),
209-
...transitiveDependencies
210-
.where((m) => m.macroConstructors.isNotEmpty)
211-
.expand((m) =>
212-
['--precompiled-macro', '${precompiledMacroArg(m, toUri)};']),
213201
'-o',
214202
'$output',
215203
];
@@ -222,9 +210,6 @@ class DDCStep implements IOModularStep {
222210
void notifyCached(Module module) {
223211
if (_options.verbose) print('\ncached step: ddc on $module');
224212
}
225-
226-
@override
227-
bool shouldExecute(Module module) => true;
228213
}
229214

230215
class RunD8 implements IOModularStep {
@@ -287,9 +272,6 @@ class RunD8 implements IOModularStep {
287272
void notifyCached(Module module) {
288273
if (_options.verbose) print('\ncached step: d8 on $module');
289274
}
290-
291-
@override
292-
bool shouldExecute(Module module) => true;
293275
}
294276

295277
String get _d8executable {

pkg/dev_compiler/test/modular_suite.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ library;
99

1010
import 'package:modular_test/src/io_pipeline.dart';
1111
import 'package:modular_test/src/runner.dart';
12-
import 'package:modular_test/src/steps/macro_precompile_aot.dart';
1312

1413
import 'modular_helpers.dart';
1514

@@ -21,7 +20,6 @@ void main(List<String> args) async {
2120
'tests/modular',
2221
options,
2322
IOPipeline([
24-
PrecompileMacroAotStep(verbose: options.verbose),
2523
SourceToSummaryDillStep(),
2624
DDCStep(canaryFeatures: false),
2725
RunD8(),

pkg/dev_compiler/test/modular_suite_canary.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ library;
99

1010
import 'package:modular_test/src/io_pipeline.dart';
1111
import 'package:modular_test/src/runner.dart';
12-
import 'package:modular_test/src/steps/macro_precompile_aot.dart';
1312

1413
import 'modular_helpers.dart';
1514

@@ -21,7 +20,6 @@ void main(List<String> args) async {
2120
'tests/modular',
2221
options,
2322
IOPipeline([
24-
PrecompileMacroAotStep(verbose: options.verbose),
2523
SourceToSummaryDillStep(),
2624
DDCStep(canaryFeatures: true),
2725
RunD8(),

pkg/front_end/lib/src/api_unstable/ddc.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,6 @@ Future<InitializedCompilerState> initializeIncrementalCompiler(
161161
required Map<ExperimentalFlag, bool> explicitExperimentalFlags,
162162
required Map<String, String> environmentDefines,
163163
bool trackNeededDillLibraries = false,
164-
bool requirePrebuiltMacros = false,
165-
List<String> precompiledMacros = const [],
166164
required NnbdMode nnbdMode}) {
167165
return modular.initializeIncrementalCompiler(
168166
oldState,

pkg/modular_test/lib/src/io_pipeline.dart

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,6 @@ abstract class IOModularStep extends ModularStep {
2626
/// should be stored under `root.resolveUri(toUri(module, resultKind))`.
2727
Future<void> execute(Module module, Uri root, ModuleDataToRelativeUri toUri,
2828
List<String> flags);
29-
30-
/// Whether this step should apply to [module]. Most steps apply to all
31-
/// modules, but not all.
32-
bool shouldExecute(Module module) => true;
3329
}
3430

3531
class IOPipeline extends Pipeline<IOModularStep> {
@@ -104,9 +100,6 @@ class IOPipeline extends Pipeline<IOModularStep> {
104100
@override
105101
Future<void> runStep(IOModularStep step, Module module,
106102
Map<Module, Set<DataId>> visibleData, List<String> flags) async {
107-
// Skip it if we aren't expected to run.
108-
if (!step.shouldExecute(module)) return;
109-
110103
final resultsFolderUri = _resultsFolderUri!;
111104
if (cacheSharedModules && module.isShared) {
112105
// If all expected outputs are already available, skip the step.
@@ -134,13 +127,8 @@ class IOPipeline extends Pipeline<IOModularStep> {
134127
for (var dataId in visibleData[module]!) {
135128
var assetUri = resultsFolderUri
136129
.resolve(_toFileName(module, dataId, configSpecific: true));
137-
var originalFile = File.fromUri(assetUri);
138-
// Some steps don't actually have an output, if they implement
139-
// shouldExecute.
140-
if (!(await originalFile.exists())) continue;
141-
var newPath =
142-
stepFolder.uri.resolve(_toFileName(module, dataId)).toFilePath();
143-
await originalFile.copy(newPath);
130+
await File.fromUri(assetUri).copy(
131+
stepFolder.uri.resolve(_toFileName(module, dataId)).toFilePath());
144132
}
145133
}
146134
if (step.needsSources) {
@@ -163,10 +151,9 @@ class IOPipeline extends Pipeline<IOModularStep> {
163151
"Step '${step.runtimeType}' on module '${module.name}' didn't "
164152
"produce an output file");
165153
}
166-
var newPath = resultsFolderUri
154+
await outputFile.copy(resultsFolderUri
167155
.resolve(_toFileName(module, dataId, configSpecific: true))
168-
.toFilePath();
169-
await outputFile.copy(newPath);
156+
.toFilePath());
170157
}
171158
await stepFolder.delete(recursive: true);
172159
}

pkg/modular_test/lib/src/loader.dart

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Future<ModularTest> loadTest(Uri uri) async {
6060
}
6161
var relativeUri = Uri.parse(fileName);
6262
var isMain = moduleName == 'main';
63-
var module = Module(moduleName, [], testUri, [relativeUri], {},
63+
var module = Module(moduleName, [], testUri, [relativeUri],
6464
mainSource: isMain ? relativeUri : null,
6565
isMain: isMain,
6666
packageBase: Uri.parse('.'));
@@ -87,7 +87,7 @@ Future<ModularTest> loadTest(Uri uri) async {
8787
return _moduleConflict(moduleName, modules[moduleName]!, testUri);
8888
}
8989
var sources = await _listModuleSources(entryUri);
90-
modules[moduleName] = Module(moduleName, [], testUri, sources, {},
90+
modules[moduleName] = Module(moduleName, [], testUri, sources,
9191
packageBase: Uri.parse('$moduleName/'));
9292
}
9393
}
@@ -109,7 +109,6 @@ Future<ModularTest> loadTest(Uri uri) async {
109109
await _addModulePerPackage(spec.packages, testUri, modules);
110110
_attachDependencies(spec.dependencies, modules);
111111
_attachDependencies(defaultTestSpecification.dependencies, modules);
112-
_attachMacros(spec.macros, modules);
113112
_addSdkDependencies(modules, sdkModule);
114113
_detectCyclesAndRemoveUnreachable(modules, mainModule);
115114
var sortedModules = modules.values.toList()
@@ -155,20 +154,6 @@ void _attachDependencies(
155154
});
156155
}
157156

158-
void _attachMacros(Map<String, Map<String, Map<String, List<String>>>> macros,
159-
Map<String, Module> modules) {
160-
macros.forEach((name, macroConstructors) {
161-
final module = modules[name];
162-
if (module == null) {
163-
_invalidTest("declared macros for a nonexistent module named '$name'");
164-
}
165-
if (module.macroConstructors.isNotEmpty) {
166-
_invalidTest("Module macros have already been declared on $name.");
167-
}
168-
module.macroConstructors.addAll(macroConstructors);
169-
});
170-
}
171-
172157
/// Make every module depend on the sdk module.
173158
void _addSdkDependencies(Map<String, Module> modules, Module sdkModule) {
174159
for (var module in modules.values) {
@@ -192,8 +177,7 @@ Future<void> _addModulePerPackage(Map<String, String> packages, Uri configRoot,
192177
// TODO(sigmund): validate that we don't use a different alias for a
193178
// module that is part of the test (package name and module name should
194179
// match).
195-
modules[packageName] = Module(
196-
packageName, [], packageRootUri, sources, {},
180+
modules[packageName] = Module(packageName, [], packageRootUri, sources,
197181
isPackage: true, packageBase: Uri.parse('lib/'), isShared: true);
198182
}
199183
}
@@ -221,7 +205,7 @@ Future<Module> _createSdkModule(Uri root) async {
221205
}
222206
}
223207
sources.sort((a, b) => a.path.compareTo(b.path));
224-
return Module('sdk', [], root, sources, {}, isSdk: true, isShared: true);
208+
return Module('sdk', [], root, sources, isSdk: true, isShared: true);
225209
}
226210

227211
/// Trim the set of modules, and detect cycles while we are at it.

0 commit comments

Comments
 (0)