Skip to content

Commit a29fcea

Browse files
committed
Merge branch 'develop' for release 1.1.0
2 parents ca370cb + c60e1fe commit a29fcea

40 files changed

+1246
-416
lines changed

bin/hackunit

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,30 @@
55
$basedir = __DIR__;
66

77
do {
8-
if (file_exists($basedir.'/composer.json') &&
9-
file_exists($basedir.'/vendor/autoload.php')) {
10-
require_once ($basedir.'/vendor/autoload.php');
11-
break;
8+
if (file_exists($basedir.'/composer.json')) {
9+
if (file_exists($basedir.'/vendor/hh_autoload.php')) {
10+
require_once $basedir.'/vendor/hh_autoload.php';
11+
break;
12+
}
13+
elseif (file_exists($basedir.'/vendor/autoload.php')) {
14+
require_once $basedir.'/vendor/autoload.php';
15+
break;
16+
}
1217
}
1318
$basedir = dirname($basedir);
1419
if ($basedir === '/') {
1520
echo
21+
'Unable to find Composer generated autoloader'.
22+
PHP_EOL.
1623
'You must set up the project dependencies using the following commands:'.
1724
PHP_EOL.
1825
'curl -s http://getcomposer.org/installer | hhvm'.
1926
PHP_EOL.
20-
'php composer.phar install'.
27+
'hhvm composer.phar install'.
2128
PHP_EOL
2229
;
2330
exit(1);
2431
}
2532
} while (true);
2633

27-
HackPack\HackUnit\HackUnit::run(
28-
HackPack\HackUnit\Util\Options::fromCli($_SERVER['argv']),
29-
);
34+
HackPack\HackUnit\Util\Builder::fromCli($_SERVER['argv'])->build()->run();

circle.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ dependencies:
1111

1212
test:
1313
override:
14-
- docker run -v "$(pwd)":"$(pwd)" --workdir="$(pwd)" --rm hhvm/hhvm:3.15-lts-latest hhvm -c test.ini test.php
14+
- docker run -v "$(pwd)":"$(pwd)" --workdir="$(pwd)" -e "CIRCLE_TEST_REPORTS=$CIRCLE_TEST_REPORTS" hhvm/hhvm:3.15-lts-latest hhvm -c test/self-test.ini test/self-test.php

composer.json

Lines changed: 47 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,52 @@
11
{
2-
"name": "hackpack/hackunit",
3-
"description": "An xUnit testing framework for Hack",
4-
"type": "library",
5-
"keywords": ["testing", "xunit", "hack", "hhvm", "hacklang"],
6-
"license": "MIT",
7-
"authors": [
8-
{
9-
"name": "Brian Scaturro",
10-
"email": "scaturrob@gmail.com",
11-
"role": "Creator"
12-
},
13-
{
14-
"name": "Isaac Leinweber",
15-
"email": "brotchen@gmail.com",
16-
"role": "Developer"
17-
}
18-
],
19-
"minimum-stability" : "dev",
20-
"require": {
21-
"hhvm": "^3.11",
22-
"facebook/definition-finder": "^1.0"
23-
},
24-
"autoload": {
25-
"psr-4": {
26-
"HackPack\\HackUnit\\": "src/"
27-
},
28-
"files": [
29-
"src/Event/Listeners.php"
30-
]
2+
"name": "hackpack/hackunit",
3+
"description": "An xUnit testing framework for Hack",
4+
"type": "library",
5+
"keywords": [
6+
"testing",
7+
"xunit",
8+
"hack",
9+
"hhvm",
10+
"hacklang"
11+
],
12+
"license": "MIT",
13+
"authors": [
14+
{
15+
"name": "Brian Scaturro",
16+
"email": "scaturrob@gmail.com",
17+
"role": "Creator"
3118
},
32-
"autoload-dev": {
33-
"psr-4": {
34-
"HackPack\\HackUnit\\Tests\\": "test"
35-
}
19+
{
20+
"name": "Isaac Leinweber",
21+
"email": "brotchen@gmail.com",
22+
"role": "Developer"
23+
}
24+
],
25+
"minimum-stability": "dev",
26+
"require": {
27+
"hhvm": "^3.11",
28+
"facebook/definition-finder": "^1.0"
29+
},
30+
"autoload": {
31+
"psr-4": {
32+
"HackPack\\HackUnit\\": "src/"
3633
},
37-
"bin": ["bin/hackunit"],
38-
"scripts": {
39-
"test": ["HackPack\\HackUnit\\HackUnit::selfTest"],
40-
"format": "hh_format src; hh_format test;"
34+
"files": [
35+
"src/Event/Listeners.php"
36+
]
37+
},
38+
"autoload-dev": {
39+
"psr-4": {
40+
"HackPack\\HackUnit\\Tests\\": "test"
4141
}
42+
},
43+
"bin": [
44+
"bin/hackunit"
45+
],
46+
"scripts": {
47+
"test": [
48+
"hhvm test/self-test.php"
49+
],
50+
"format": "hh_format src; hh_format test;"
51+
}
4252
}

docker-test.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
#! /usr/bin/env bash
1+
#! /usr/bin/env sh
22

3-
exec docker run -v "$(pwd)":"$(pwd)" --workdir="$(pwd)" --rm hhvm/hhvm:3.15-lts-latest hhvm -c test.ini test.php
3+
exec docker run -v "$(pwd)":"$(pwd)" --workdir="$(pwd)" --rm hhvm/hhvm:3.15-lts-latest hhvm -c test/self-test.ini test/self-test.php

src/Assert.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ public function container<T>(
7979
);
8080
}
8181

82-
public function keyedContainer<Tkey,Tval>(
83-
KeyedContainer<Tkey,Tval> $context,
84-
): Contract\Assertion\KeyedContainerAssertion<Tkey,Tval> {
82+
public function keyedContainer<Tkey, Tval>(
83+
KeyedContainer<Tkey, Tval> $context,
84+
): Contract\Assertion\KeyedContainerAssertion<Tkey, Tval> {
8585
return new Assertion\KeyedContainerAssertion(
8686
$context,
8787
$this->failureListeners,
@@ -94,7 +94,6 @@ public function skip(
9494
?Util\TraceItem $traceItem = null,
9595
): void {
9696
if ($traceItem === null) {
97-
// Assume the caller was a test method
9897
$stack = Util\Trace::generate();
9998
$traceItem = shape(
10099
'file' => $stack[0]['file'],
@@ -103,7 +102,7 @@ public function skip(
103102
'class' => $stack[1]['class'],
104103
);
105104
}
106-
$skip = new Event\Skip($reason, $traceItem);
105+
$skip = new Event\Skip($reason, $traceItem, Util\Trace::findTestMethod());
107106
foreach ($this->skipListeners as $l) {
108107
$l($skip);
109108
}

src/Contract/Test/Suite.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@
33
namespace HackPack\HackUnit\Contract\Test;
44

55
use HackPack\HackUnit\Contract\Assert;
6+
use HackPack\HackUnit\Event\TestStartListener;
67

78
interface Suite {
89
public function up(): Awaitable<void>;
910
public function run(
1011
Assert $assert,
1112
(function(): void) $testPassed,
13+
\ConstVector<TestStartListener> $testStartListeners,
1214
): Awaitable<void>;
1315
public function down(): Awaitable<void>;
16+
public function name(): string;
1417
}

src/Event/BuildFailure.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?hh // strict
2+
3+
namespace HackPack\HackUnit\Event;
4+
5+
final class BuildFailure {
6+
public function __construct(
7+
private string $path,
8+
private \Exception $exception,
9+
) {}
10+
11+
public function filePath(): string {
12+
return $this->path;
13+
}
14+
15+
public function exception(): \Exception {
16+
return $this->exception;
17+
}
18+
}

src/Event/Failure.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
use HackPack\HackUnit\Util\Trace;
66
use HackPack\HackUnit\Util\TraceItem;
77

8-
<<__ConsistentConstruct>>
9-
class Failure {
8+
final class Failure {
109
public static function fromCallStack(string $message): this {
1110
return new static(
1211
$message,

src/Event/Listeners.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22

33
namespace HackPack\HackUnit\Event;
44

5+
type BuildFailureListener = (function(BuildFailure): void);
56
type ExceptionListener = (function(\Exception): void);
67
type FailureListener = (function(Failure): void);
78
type MalformedSuiteListener = (function(MalformedSuite): void);
8-
type PassListener = (function(): void);
9+
type PassListener = (function(Pass): void);
910
type RunEndListener = (function(): void);
1011
type RunStartListener = (function(): void);
1112
type SkipListener = (function(Skip): void);
12-
type SuccessListener = (function(): void);
13+
type SuccessListener = (function(Success): void);
1314
type SuiteEndListener = (function(): void);
14-
type SuiteStartListener = (function(): void);
15+
type SuiteStartListener = (function(SuiteStart): void);
16+
type TestStartListener = (function(TestStart): void);

src/Event/Pass.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?hh // strict
2+
3+
namespace HackPack\HackUnit\Event;
4+
5+
use HackPack\HackUnit\Util\Trace;
6+
use HackPack\HackUnit\Util\TraceItem;
7+
8+
final class Pass {
9+
public static function fromCallStack(): this {
10+
return new static(Trace::findTestMethod());
11+
}
12+
public function __construct(private TraceItem $testCallSite) {}
13+
14+
public function testMethodTraceItem(): TraceItem {
15+
return $this->testCallSite;
16+
}
17+
}

0 commit comments

Comments
 (0)