Skip to content

Commit 3daa47b

Browse files
rmacnak-googleCommit Queue
authored and
Commit Queue
committed
[test_runner] Don't assign all vm/cc tests to the first shard.
Before: ./tools/test.py --shards=10 --shard=1 --list | wc -l # 3664 ./tools/test.py --shards=10 --shard=2 --list | wc -l # 1047 ./tools/test.py --shards=10 --shard=3 --list | wc -l # 1146 After: ./tools/test.py --shards=10 --shard=1 --list | wc -l # 1408 ./tools/test.py --shards=10 --shard=2 --list | wc -l # 1306 ./tools/test.py --shards=10 --shard=3 --list | wc -l # 1381 Change-Id: I2107779e79d85976c04db7c01c11581a8d9895b0 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313280 Reviewed-by: William Hesse <[email protected]> Commit-Queue: Ryan Macnak <[email protected]>
1 parent 89e24c1 commit 3daa47b

File tree

3 files changed

+11
-17
lines changed

3 files changed

+11
-17
lines changed

pkg/test_runner/lib/src/test_file.dart

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,6 @@ List<String> _parseStringOption(String filePath, String contents, String name,
4040
_parseOption<String>(filePath, contents, name, (string) => string,
4141
allowMultiple: allowMultiple);
4242

43-
// Fake path used as sentinel for test files that don't have a path.
44-
final _fakePath = Path('/fake');
45-
4643
abstract class _TestFileBase {
4744
/// The test suite directory containing this test.
4845
final Path? _suiteDirectory;
@@ -93,9 +90,9 @@ abstract class _TestFileBase {
9390
int get shardHash {
9491
// The VM C++ unit tests have a special fake TestFile with no suite
9592
// directory or path. Don't crash in that case.
96-
// TODO(rnystrom): Is there a cleaner solution? Should we use the C++ file
97-
// as the path for the TestFile?
98-
if (originPath == _fakePath) return 0;
93+
if (_suiteDirectory == null) {
94+
return path.toString().hashCode;
95+
}
9996

10097
return originPath.relativeTo(_suiteDirectory!).toString().hashCode;
10198
}
@@ -318,7 +315,7 @@ class TestFile extends _TestFileBase {
318315
}
319316

320317
/// A special fake test file for representing a VM unit test written in C++.
321-
TestFile.vmUnitTest(
318+
TestFile.vmUnitTest(String name,
322319
{required this.hasCompileError,
323320
required this.hasRuntimeError,
324321
required this.hasCrash})
@@ -338,7 +335,7 @@ class TestFile extends _TestFileBase {
338335
otherResources = [],
339336
experiments = [],
340337
isVmIntermediateLanguageTest = false,
341-
super(null, _fakePath, []);
338+
super(null, Path("/fake/vm/cc/$name"), []);
342339

343340
TestFile._(Path suiteDirectory, Path path, List<StaticError> expectedErrors,
344341
{this.packages,

pkg/test_runner/lib/src/test_suite.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ class VMTestSuite extends TestSuite {
322322
}
323323

324324
// Update the new workflow based expectations to include [testExpectation].
325-
var testFile = TestFile.vmUnitTest(
325+
var testFile = TestFile.vmUnitTest(test.name,
326326
hasCompileError: testExpectation == Expectation.compileTimeError,
327327
hasRuntimeError: testExpectation == Expectation.runtimeError,
328328
hasCrash: testExpectation == Expectation.crash);
@@ -461,7 +461,7 @@ class FfiTestSuite extends TestSuite {
461461
}
462462

463463
// Update the new workflow based expectations to include [testExpectation].
464-
final testFile = TestFile.vmUnitTest(
464+
final testFile = TestFile.vmUnitTest(test.name,
465465
hasCompileError: testExpectation == Expectation.compileTimeError,
466466
hasRuntimeError: testExpectation == Expectation.runtimeError,
467467
hasCrash: testExpectation == Expectation.crash);

pkg/test_runner/test/test_file_test.dart

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -783,13 +783,10 @@ void testShardHash() {
783783
var testFile = parseTestFile("", path: "a_test.dart");
784784
Expect.type<int>(testFile.shardHash);
785785

786-
// VM test files are hard-coded to return hash zero because they don't have a
787-
// path to base the hash on.
788-
Expect.equals(
789-
0,
790-
TestFile.vmUnitTest(
791-
hasCompileError: false, hasCrash: false, hasRuntimeError: false)
792-
.shardHash);
786+
// VM test files are based on a fake path.
787+
testFile = TestFile.vmUnitTest("ExampleTestName",
788+
hasCompileError: false, hasCrash: false, hasRuntimeError: false);
789+
Expect.type<int>(testFile.shardHash);
793790
}
794791

795792
void expectParseErrorExpectations(String source, List<StaticError> errors) {

0 commit comments

Comments
 (0)