[pkg/modular_test] use package:lints/recommended.yaml

Change-Id: Icbd17513120846322df2923feb7d18abd82d3ece
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/282385
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
This commit is contained in:
Devon Carew
2023-02-10 23:50:31 +00:00
committed by Commit Queue
parent c6352b0e49
commit b4072ff64f
13 changed files with 100 additions and 18 deletions
+1 -1
View File
@@ -1 +1 @@
include: package:lints/core.yaml
include: package:lints/recommended.yaml
@@ -62,7 +62,7 @@ Future<void> writePackageConfig(
String _packageConfigEntry(String name, Uri root,
{Uri? packageRoot, LanguageVersion? version}) {
var fields = [
'"name": "${name}"',
'"name": "$name"',
'"rootUri": "$root"',
if (packageRoot != null) '"packageUri": "$packageRoot"',
if (version != null) '"languageVersion": "$version"'
+1 -1
View File
@@ -171,5 +171,5 @@ Future<void> runSuite<T>(List<Test> tests, RunnerOptions options) async {
.writeAsStringSync(results.map((s) => '$s\n').join(), flush: true);
File.fromUri(logsJsonUri)
.writeAsStringSync(logs.map((s) => '$s\n').join(), flush: true);
print('log files emitted to ${resultJsonUri} and ${logsJsonUri}');
print('log files emitted to $resultJsonUri and $logsJsonUri');
}
+1 -1
View File
@@ -120,7 +120,7 @@ class IOPipeline extends Pipeline<IOModularStep> {
// issues, we include one of the step data ids in the name of the folder.
var stepId = step.resultData.first;
var stepFolder =
await Directory.systemTemp.createTemp('modular_test_${stepId}-');
await Directory.systemTemp.createTemp('modular_test_$stepId-');
for (var module in visibleData.keys) {
for (var dataId in visibleData[module]!) {
var assetUri = resultsFolderUri
+3 -2
View File
@@ -141,14 +141,14 @@ void _attachDependencies(
if (module.dependencies.isNotEmpty) {
_invalidTest("Module dependencies have already been declared on $name.");
}
moduleDependencies.forEach((dependencyName) {
for (var dependencyName in moduleDependencies) {
final moduleDependency = modules[dependencyName];
if (moduleDependency == null) {
_invalidTest("'$name' declares a dependency on a nonexistent module "
"named '$dependencyName'");
}
module.dependencies.add(moduleDependency);
});
}
});
}
@@ -273,6 +273,7 @@ Never _invalidTest(String message) {
class InvalidTestError extends Error {
final String message;
InvalidTestError(this.message);
@override
String toString() => "Invalid test: $message";
}
@@ -44,7 +44,7 @@ class MemoryPipeline extends Pipeline<MemoryModularStep> {
@override
Future<void> run(ModularTest test) async {
var results = _results = {};
Map<Module, Map<DataId, Object>>? cache = null;
Map<Module, Map<DataId, Object>>? cache;
if (cacheSharedModules) {
int id = _registry!.computeConfigurationId(test);
if (id < _resultCache.length) {
@@ -94,10 +94,10 @@ class MemoryPipeline extends Pipeline<MemoryModularStep> {
});
Map<Uri, String> inputSources = {};
if (step.needsSources) {
module.sources.forEach((relativeUri) {
for (var relativeUri in module.sources) {
var uri = module.rootUri.resolveUri(relativeUri);
inputSources[uri] = _sources[uri]!;
});
}
}
Map<DataId, Object> result = await step.execute(
module,
+5 -4
View File
@@ -110,14 +110,14 @@ abstract class Pipeline<S extends ModularStep> {
for (var dataId in step.dependencyDataNeeded) {
if (!previousKinds.containsKey(dataId)) {
_validationError(
"Step '${step.runtimeType}' needs data '${dataId}', but the "
"Step '${step.runtimeType}' needs data '$dataId', but the "
"data is not produced by this or a preceding step.");
}
}
for (var dataId in step.moduleDataNeeded) {
if (!previousKinds.containsKey(dataId)) {
_validationError(
"Step '${step.runtimeType}' needs data '${dataId}', but the "
"Step '${step.runtimeType}' needs data '$dataId', but the "
"data is not produced by a preceding step.");
}
if (dataId == resultKind) {
@@ -160,14 +160,14 @@ abstract class Pipeline<S extends ModularStep> {
// Include only requested data from transitive dependencies.
Map<Module, Set<DataId>> visibleData = {};
deps.forEach((dep) {
for (var dep in deps) {
visibleData[dep] = {};
for (var dataId in step.dependencyDataNeeded) {
if (computedData[dep]!.contains(dataId)) {
visibleData[dep]!.add(dataId);
}
}
});
}
visibleData[module] = {};
for (var dataId in step.moduleDataNeeded) {
if (computedData[module]!.contains(dataId)) {
@@ -185,5 +185,6 @@ abstract class Pipeline<S extends ModularStep> {
class InvalidPipelineError extends Error {
final String message;
InvalidPipelineError(this.message);
@override
String toString() => "Invalid pipeline: $message";
}
+2
View File
@@ -39,6 +39,7 @@ Future<void> runSuite(Uri suiteFolder, String suiteName, Options options,
}
class _PipelineTest implements generic.Test {
@override
final String name;
final Uri uri;
final Options options;
@@ -49,6 +50,7 @@ class _PipelineTest implements generic.Test {
// from the suite and the trailing `/`.
: name = uri.path.substring(suiteFolder.path.length, uri.path.length - 1);
@override
Future<void> run() async {
ModularTest test = await loadTest(uri);
if (options.verbose) print(test.debugString());
+2 -1
View File
@@ -148,7 +148,7 @@ Set<Module> computeTransitiveDependencies(Module module) {
/// of flags (the same configuration), and thus pipelines could reuse the
/// results of shared modules from the first test when running the second test.
class ConfigurationRegistry {
Map<String, int> _configurationId = {};
final Map<String, int> _configurationId = {};
/// Compute an id to identify the configuration of a modular test.
///
@@ -164,5 +164,6 @@ class ConfigurationRegistry {
class InvalidModularTestError extends Error {
final String message;
InvalidModularTestError(this.message);
@override
String toString() => "Invalid modular test: $message";
}
@@ -76,12 +76,12 @@ TestSpecification parseTestSpecification(String contents) {
if (value is String) {
values.add(value);
} else if (value is List) {
value.forEach((entry) {
for (var entry in value) {
if (entry is! String) {
_invalidSpecification("entry: '$entry' is not a string");
}
values.add(entry);
});
}
} else {
_invalidSpecification(
"entry: '$value' is not a string or a list of strings");
@@ -144,5 +144,6 @@ _invalidSpecification(String message) {
class InvalidSpecificationError extends Error {
final String message;
InvalidSpecificationError(this.message);
@override
String toString() => "Invalid specification: $message";
}
@@ -102,12 +102,19 @@ class IOPipelineTestStrategy implements PipelineTestStrategy<IOModularStep> {
class SourceOnlyStep implements IOModularStep {
final String Function(Map<Uri, String?>) action;
final DataId resultId;
@override
final bool needsSources;
@override
List<DataId> get dependencyDataNeeded => const [];
@override
List<DataId> get moduleDataNeeded => const [];
@override
List<DataId> get resultData => [resultId];
@override
bool get onlyOnMain => false;
@override
bool get onlyOnSdk => false;
@override
bool get notOnSdk => false;
SourceOnlyStep(this.action, this.resultId, this.needsSources);
@@ -131,14 +138,21 @@ class SourceOnlyStep implements IOModularStep {
class ModuleDataStep implements IOModularStep {
final String Function(String) action;
@override
bool get needsSources => false;
@override
List<DataId> get dependencyDataNeeded => const [];
@override
final List<DataId> moduleDataNeeded;
@override
List<DataId> get resultData => [resultId];
final DataId resultId;
final DataId inputId;
@override
bool get onlyOnMain => false;
@override
bool get onlyOnSdk => false;
@override
bool get notOnSdk => false;
ModuleDataStep(this.action, this.inputId, this.resultId, bool requestInput)
@@ -161,15 +175,22 @@ class ModuleDataStep implements IOModularStep {
class TwoOutputStep implements IOModularStep {
final String Function(String) action1;
final String Function(String) action2;
@override
bool get needsSources => false;
@override
List<DataId> get dependencyDataNeeded => const [];
@override
List<DataId> get moduleDataNeeded => [inputId];
@override
List<DataId> get resultData => [result1Id, result2Id];
final DataId result1Id;
final DataId result2Id;
final DataId inputId;
@override
bool get onlyOnMain => false;
@override
bool get onlyOnSdk => false;
@override
bool get notOnSdk => false;
TwoOutputStep(
@@ -194,16 +215,23 @@ class TwoOutputStep implements IOModularStep {
}
class LinkStep implements IOModularStep {
@override
bool get needsSources => false;
@override
final List<DataId> dependencyDataNeeded;
@override
List<DataId> get moduleDataNeeded => [inputId];
@override
List<DataId> get resultData => [resultId];
final String Function(String, List<String?>) action;
final DataId inputId;
final DataId depId;
final DataId resultId;
@override
bool get onlyOnMain => false;
@override
bool get onlyOnSdk => false;
@override
bool get notOnSdk => false;
LinkStep(this.action, this.inputId, this.depId, this.resultId,
@@ -228,16 +256,23 @@ class LinkStep implements IOModularStep {
}
class MainOnlyStep implements IOModularStep {
@override
bool get needsSources => false;
@override
final List<DataId> dependencyDataNeeded;
@override
List<DataId> get moduleDataNeeded => [inputId];
@override
List<DataId> get resultData => [resultId];
final String Function(String, List<String?>) action;
final DataId inputId;
final DataId depId;
final DataId resultId;
@override
bool get onlyOnMain => true;
@override
bool get onlyOnSdk => false;
@override
bool get notOnSdk => false;
MainOnlyStep(this.action, this.inputId, this.depId, this.resultId,
@@ -87,9 +87,9 @@ String _dumpAsText(ModularTest test) {
} else if (module.isSdk) {
buffer.write('\n (sdk sources omitted)');
} else {
module.sources.forEach((uri) {
for (var uri in module.sources) {
buffer.write('\n $uri');
});
}
}
buffer.write('\n');
@@ -76,22 +76,31 @@ class MemoryPipelineTestStrategy
return pipeline.resultsForTesting![m]![dataId] as String?;
}
@override
FutureOr<void> cleanup(Pipeline<MemoryModularStep> pipeline) => null;
}
class SourceOnlyStep implements MemoryModularStep {
final String Function(Map<Uri, String?>) action;
final DataId resultId;
@override
final bool needsSources;
@override
List<DataId> get dependencyDataNeeded => const [];
@override
List<DataId> get moduleDataNeeded => const [];
@override
List<DataId> get resultData => [resultId];
@override
bool get onlyOnMain => false;
@override
bool get onlyOnSdk => false;
@override
bool get notOnSdk => false;
SourceOnlyStep(this.action, this.resultId, this.needsSources);
@override
Future<Map<DataId, Object>> execute(
Module module,
SourceProvider sourceProvider,
@@ -110,19 +119,27 @@ class SourceOnlyStep implements MemoryModularStep {
class ModuleDataStep implements MemoryModularStep {
final String Function(String) action;
@override
bool get needsSources => false;
@override
List<DataId> get dependencyDataNeeded => const [];
@override
final List<DataId> moduleDataNeeded;
@override
List<DataId> get resultData => [resultId];
final DataId resultId;
final DataId inputId;
@override
bool get onlyOnMain => false;
@override
bool get onlyOnSdk => false;
@override
bool get notOnSdk => false;
ModuleDataStep(this.action, this.inputId, this.resultId, bool requestInput)
: moduleDataNeeded = requestInput ? [inputId] : [];
@override
Future<Map<DataId, Object>> execute(
Module module,
SourceProvider sourceProvider,
@@ -142,20 +159,28 @@ class ModuleDataStep implements MemoryModularStep {
class TwoOutputStep implements MemoryModularStep {
final String Function(String) action1;
final String Function(String) action2;
@override
bool get needsSources => false;
@override
List<DataId> get dependencyDataNeeded => const [];
@override
List<DataId> get moduleDataNeeded => [inputId];
@override
List<DataId> get resultData => [result1Id, result2Id];
final DataId result1Id;
final DataId result2Id;
final DataId inputId;
@override
bool get onlyOnMain => false;
@override
bool get onlyOnSdk => false;
@override
bool get notOnSdk => false;
TwoOutputStep(
this.action1, this.action2, this.inputId, this.result1Id, this.result2Id);
@override
Future<Map<DataId, Object>> execute(
Module module,
SourceProvider sourceProvider,
@@ -177,22 +202,30 @@ class TwoOutputStep implements MemoryModularStep {
}
class LinkStep implements MemoryModularStep {
@override
bool get needsSources => false;
@override
final List<DataId> dependencyDataNeeded;
@override
List<DataId> get moduleDataNeeded => [inputId];
final String Function(String, List<String?>) action;
final DataId inputId;
final DataId depId;
final DataId resultId;
@override
List<DataId> get resultData => [resultId];
@override
bool get onlyOnMain => false;
@override
bool get onlyOnSdk => false;
@override
bool get notOnSdk => false;
LinkStep(this.action, this.inputId, this.depId, this.resultId,
bool requestDependencies)
: dependencyDataNeeded = requestDependencies ? [depId] : [];
@override
Future<Map<DataId, Object>> execute(
Module module,
SourceProvider sourceProvider,
@@ -210,22 +243,30 @@ class LinkStep implements MemoryModularStep {
}
class MainOnlyStep implements MemoryModularStep {
@override
bool get needsSources => false;
@override
final List<DataId> dependencyDataNeeded;
@override
List<DataId> get moduleDataNeeded => [inputId];
final String Function(String, List<String?>) action;
final DataId inputId;
final DataId depId;
final DataId resultId;
@override
List<DataId> get resultData => [resultId];
@override
bool get onlyOnMain => true;
@override
bool get onlyOnSdk => false;
@override
bool get notOnSdk => false;
MainOnlyStep(this.action, this.inputId, this.depId, this.resultId,
bool requestDependencies)
: dependencyDataNeeded = requestDependencies ? [depId] : [];
@override
Future<Map<DataId, Object>> execute(
Module module,
SourceProvider sourceProvider,