-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun-test.php
39 lines (28 loc) · 909 Bytes
/
run-test.php
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
<?php
use TaskChecker\Codebot\EvalClient;
use TaskChecker\Errors\BaseTestError;
use TaskChecker\ModuleFactory;
use TaskChecker\Reporter\ConsolePrinter;
use TaskChecker\Reporter\Report;
use TaskChecker\Test\ScenarioTest;
require_once __DIR__ . '/../src/bootstrap.php';
$codebot = new EvalClient();
$moduleFactory = new ModuleFactory($codebot);
$testFile = $argv[1];
$codeFile = $argv[2];
if (!file_exists($testFile)) {
throw new \Exception("File not exists: $testFile");
}
if (!file_exists($codeFile)) {
throw new \Exception("File not exists: $codeFile");
}
$code = file_get_contents($codeFile);
$test = new ScenarioTest($testFile, $moduleFactory);
$report = $test->run($code);
if ($report->isFailed()) {
printf("Failed: %s\n\n", $report->getLastError()->getErrorText());
} else {
printf("Success\n\n");
}
$consolePrinter = new ConsolePrinter;
$consolePrinter->printReport($report);