60ef62a889
Change-Id: Ic1d006e6ce1596d5e4cb0f4e2222912d383c80ed Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/163063 Reviewed-by: Johnni Winther <johnniwinther@google.com> Commit-Queue: Jens Johansen <jensj@google.com>
43 lines
1.4 KiB
Dart
43 lines
1.4 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);
|
|
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: ${environmentKeys.toList()}.\n"
|
|
"Knows about ${knownEnvironmentKeys.toList()}";
|
|
}
|
|
}
|