-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest
More file actions
executable file
·94 lines (84 loc) · 2.68 KB
/
Copy pathtest
File metadata and controls
executable file
·94 lines (84 loc) · 2.68 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/usr/bin/env php
<?php
/**
* @license MIT
* Copyright 2022 Dustin Wilson, et al.
* See LICENSE and AUTHORS files for details
*/
$dir = ini_get('extension_dir');
$php = escapeshellarg(\PHP_BINARY);
$code = escapeshellarg(__DIR__ . '/lib');
const BASE = __DIR__ . DIRECTORY_SEPARATOR;
const BASE_TEST = BASE . "tests" . DIRECTORY_SEPARATOR;
$repos = [
'html5lib-tests' => [
'url' => 'https://github.com/html5lib/html5lib-tests',
'sparse' => null
],
'platform-tests' => [
'url' => 'https://github.com/web-platform-tests/wpt',
'sparse' => 'html/syntax/xmldecl'
],
];
if (!is_dir(BASE_TEST."html5lib-tests")) {
foreach ($repos as $dir => $config) {
$path = BASE_TEST . $dir;
if (is_dir($path)) {
echo "Updating $dir...\n";
passthru("git -C " . escapeshellarg($path) . " pull");
} else {
echo "Cloning $dir...\n";
if ($config['sparse']) {
$url = escapeshellarg($config['url']);
$spath = escapeshellarg($path);
$sparse = escapeshellarg($config['sparse']);
passthru("git clone --filter=blob:none --no-checkout --depth=1 $url $spath");
passthru("git -C $spath sparse-checkout set $sparse");
passthru("git -C $spath checkout");
} else {
passthru("git clone " . escapeshellarg($config['url']) . " " . escapeshellarg($path));
}
}
}
}
array_shift($argv);
foreach ($argv as $k => $v) {
if (in_array($v, ['--coverage', '--coverage-html'])) {
$argv[$k] = '--coverage-html tests/coverage';
}
}
$cmd = [
$php,
'-d zend.assertions=1',
'-d assert.exception=true',
'-d opcache.enable_cli=0',
];
$pcovLoaded = extension_loaded('pcov');
$xdebugLoaded = extension_loaded('xdebug');
if (!$pcovLoaded && !$xdebugLoaded) {
$extDir = ini_get('extension_dir');
if (!extension_loaded('pcov') && file_exists("$extDir/pcov.so")) {
$cmd[] = '-d extension=pcov.so';
$pcovLoaded = true;
} elseif (!extension_loaded('xdebug') && file_exists("$extDir/xdebug.so")) {
$cmd[] = '-d zend_extension=xdebug.so';
$xdebugLoaded = true;
}
}
if ($pcovLoaded) {
$cmd[] = '-d pcov.enabled=1';
$cmd[] = "-d pcov.directory=$code";
} elseif ($xdebugLoaded) {
$cmd[] = '-d xdebug.mode=coverage,develop,trace';
} else {
fwrite(\STDERR, "Either the pcov or xdebug extension is required to run tests.\n");
exit(1);
}
$cmd = implode(' ', [
...$cmd,
escapeshellarg(__DIR__ . '/vendor/bin/phpunit'),
'--configuration tests/phpunit.xml',
...$argv,
'--display-deprecations'
]);
passthru($cmd);