make TESTS configurable
[m6w6/travis-pecl] / check-packagexml.php
1 #!/usr/bin/env php
2 <?php
3
4 error_reporting(E_ALL & ~(E_DEPRECATED|E_STRICT));
5
6 if ($argc < 2) {
7 fprintf(STDERR, "Usage: %s <path/to/package.xml>\n", $argv[0]);
8 exit(1);
9 }
10
11 require_once "PEAR/Config.php";
12 require_once "PEAR/PackageFile.php";
13
14 define("PACKAGE_XML", $argv[1]);
15 define("PACKAGE_DIR", dirname(PACKAGE_XML));
16
17 $factory = new PEAR_PackageFile(PEAR_Config::singleton());
18 $pf = $factory->fromPackageFile($argv[1], PEAR_VALIDATE_NORMAL);
19
20 if (PEAR::isError($pf)) {
21 fprintf(STDERR, "ERROR: %s\n", $pf->getMessage());
22 if (is_array($infos = $pf->getUserInfo())) {
23 foreach ($infos as $info) {
24 fprintf(STDERR, " %s\n", $info["message"]);
25 }
26 } elseif (strlen($infos)) {
27 fprintf(STDERR, " %s\n", $infos);
28 }
29 exit(1);
30 }
31
32 foreach ($pf->getValidationWarnings() as $warning) {
33 fprintf(STDERR, "%s: %s\n", strtoupper($warning["level"]), $warning["message"]);
34 }
35
36 $exit = 0;
37 foreach ($pf->getFilelist() as $file => $attr) {
38 if (!file_exists(PACKAGE_DIR."/".$file)) {
39 $exit++;
40 fprintf(STDERR, "File '%s' with role '%s' not found in '%s'\n",
41 $file, $attr["role"], PACKAGE_DIR);
42 }
43 }
44
45 if ($exit) {
46 fprintf(STDERR, "%3d failure(s)\n", $exit);
47 exit(1);
48 }