mirror of
https://github.com/dart-lang/sdk
synced 2024-10-03 09:10:10 +00:00
d6d5cb8a13
Change-Id: Idce9122f5e6c797d409cf861ba6b24e6b62e8fe7 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212006 Reviewed-by: Jens Johansen <jensj@google.com> Commit-Queue: Johnni Winther <johnniwinther@google.com>
50 lines
1.7 KiB
Dart
50 lines
1.7 KiB
Dart
// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
|
|
// 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' show Directory, Process, ProcessResult;
|
|
|
|
import 'package:testing/testing.dart' show Chain, TestDescription;
|
|
|
|
Stream<TestDescription> filterList(
|
|
Chain suite, bool onlyInGit, Stream<TestDescription> base) async* {
|
|
Set<Uri>? gitFiles;
|
|
if (onlyInGit) {
|
|
gitFiles = await getGitFiles(suite.uri);
|
|
}
|
|
await for (TestDescription description in base) {
|
|
if (onlyInGit && !gitFiles!.contains(description.uri)) {
|
|
continue;
|
|
}
|
|
yield description;
|
|
}
|
|
}
|
|
|
|
Future<Set<Uri>> getGitFiles(Uri uri) async {
|
|
ProcessResult result = await Process.run("git", ["ls-files", "."],
|
|
workingDirectory: new Directory.fromUri(uri).absolute.path,
|
|
runInShell: true);
|
|
if (result.exitCode != 0) {
|
|
throw "Git returned non-zero error code (${result.exitCode}):\n\n"
|
|
"stdout: ${result.stdout}\n\n"
|
|
"stderr: ${result.stderr}";
|
|
}
|
|
String stdout = result.stdout;
|
|
return stdout
|
|
.split(new RegExp('^', multiLine: true))
|
|
.map((line) => uri.resolve(line.trimRight()))
|
|
.toSet();
|
|
}
|
|
|
|
void checkEnvironment(
|
|
Map<String, String> environment, Set<String> knownEnvironmentKeys) {
|
|
Set<String> environmentKeys = environment.keys.toSet();
|
|
environmentKeys.removeAll(knownEnvironmentKeys);
|
|
if (environmentKeys.isNotEmpty) {
|
|
throw "Unknown environment(s) given:"
|
|
"\n - ${environmentKeys.join("\n- ")}\n"
|
|
"Knows about these environment(s):"
|
|
"\n - ${knownEnvironmentKeys.join("\n - ")}";
|
|
}
|
|
}
|