-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtsplit
More file actions
executable file
·50 lines (37 loc) · 1.35 KB
/
tsplit
File metadata and controls
executable file
·50 lines (37 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env php
<?php
declare(strict_types=1);
use DaveLiddament\TestSplitter\CliArgumentParser;
use DaveLiddament\TestSplitter\InvalidArgumentsException;
use DaveLiddament\TestSplitter\TestClassSplitter;
use DaveLiddament\TestSplitter\TestNameExtractor;
function loadAutoloader(): void
{
$autoloaderLocations = [
__DIR__ . '/vendor/autoload.php',
__DIR__ . '/../../autoload.php',
];
foreach ($autoloaderLocations as $autoloaderLocation) {
if (file_exists($autoloaderLocation)) {
require($autoloaderLocation);
return;
}
}
die('Can not find autoloader');
}
loadAutoloader();
try {
$cliArgumentParser = new CliArgumentParser($argv);
} catch (InvalidArgumentsException $e) {
printf("\n\nError: %s\n\n Usage: %s <set> <of>\n\n", $e->getMessage(), $argv[0]);
exit(1);
}
$stdIn = stream_get_contents(STDIN);
$testNameExtractor = new TestNameExtractor();
$testClassSplitter = new TestClassSplitter($testNameExtractor->getDeDupedTestClassNames($stdIn));
$testCaseNames = $testClassSplitter->getTestCaseNames($cliArgumentParser->getNumerator(), $cliArgumentParser->getDenominator());
$escapedTestCaseNames = array_map(function (string $testCaseName): string {
return str_replace('\\', '\\\\', $testCaseName);
}, $testCaseNames);
$output = join('|', $escapedTestCaseNames);
echo $output;