From 93bde98794e1bb50d847909bb9633b0a8f18dd79 Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Fri, 11 Jul 2014 14:16:54 +0200 Subject: [PATCH] package administrativa --- .gitignore | 1 + check_package-xml.php | 92 +++++++++++++++++++++++++++++++++++++++++++ package.xml | 73 ++++++++++++++++++++++++++-------- phpunit.php | 4 -- 4 files changed, 150 insertions(+), 20 deletions(-) create mode 100755 check_package-xml.php delete mode 100644 phpunit.php diff --git a/.gitignore b/.gitignore index 8ffc91c..64b23b6 100644 --- a/.gitignore +++ b/.gitignore @@ -36,3 +36,4 @@ tests/*.log tests/*.out tests/*.php tests/*.sh +lcov_data diff --git a/check_package-xml.php b/check_package-xml.php new file mode 100755 index 0000000..4000054 --- /dev/null +++ b/check_package-xml.php @@ -0,0 +1,92 @@ +#!/usr/bin/env php + 1) { + if ($argv[1] === "-") { + $file = "php://stdin"; + } else { + $file = $argv[1]; + } +} elseif (stdin_is_readable()) { + $file = "php://stdin"; +} else { + $file = "./package.xml"; +} + +if (($xml = simplexml_load_file($file))) { + $xml_files = xmllist($xml->contents[0]); + $dirs = ["."]; + while ($dir = array_shift($dirs)) { + foreach (dirlist($dir) as $file) { + if (is_gitignored($file)) { + continue; + } + if (!is_dir($file)) { + if (!in_array($file, $xml_files)) { + echo "Missing file $file\n"; + } + } else { + $base = basename($file); + if ($base{0} !== ".") { + array_push($dirs, $file); + } + } + } + } +} + +### + +function error($fmt) { + trigger_error(call_user_func_array("sprintf", func_get_args())); +} + +function stdin_is_readable() { + $r = [STDIN]; $w = $e = []; + return stream_select($r, $w, $e, 0); +} + +function is_gitignored($file) { + static $gitignore; + + if (!isset($gitignore)) { + if (is_readable(".gitignore")) { + $gitignore = explode("\n", `find | git check-ignore --stdin`); + } else { + $gitignore = false; + } + } + if ($gitignore) { + return in_array($file, $gitignore); + } + return false; +} + +function xmllist(SimpleXmlElement $dir, $p = ".", &$a = null) { + settype($a, "array"); + $p = trim($p, "/") . "/" . trim($dir["name"], "/") . "/"; + foreach ($dir as $file) { + switch ($file->getName()) { + case "dir": + xmllist($file, $p, $a); + break; + case "file": + $a[] = sprintf("%s/%s", trim($p, "/"), trim($file["name"])); + break; + default: + error("Unknown content type: %s", $file->getName()); + break; + } + } + return $a; +} + +function dirlist($dir, $p = null) { + $p = implode("/", array_filter([trim($p, "/"), trim($dir, "/")])); + foreach (scandir($p) as $file) { + yield $p."/".$file; + } +} diff --git a/package.xml b/package.xml index 990e99b..44f9617 100644 --- a/package.xml +++ b/package.xml @@ -37,9 +37,9 @@ v2: http://dev.iworks.at/ext-http/lcov/ext/http/ mike@php.net yes - 2014-04-24 + 2014-07-11 - 2.0.6 + 2.0.7 2.0.0 @@ -48,10 +48,13 @@ v2: http://dev.iworks.at/ext-http/lcov/ext/http/ BSD, revised @@ -159,6 +162,27 @@ v2: http://dev.iworks.at/ext-http/lcov/ext/http/ + + + + + + + + + + + + + + + + + + + + + @@ -184,6 +208,7 @@ v2: http://dev.iworks.at/ext-http/lcov/ext/http/ + @@ -218,24 +243,40 @@ v2: http://dev.iworks.at/ext-http/lcov/ext/http/ + + + + + + + + + + + + - + + + + + + + + + + - + + + + - - - - - - - - diff --git a/phpunit.php b/phpunit.php deleted file mode 100644 index 8a61937..0000000 --- a/phpunit.php +++ /dev/null @@ -1,4 +0,0 @@ -run(array_merge($argv, array(__DIR__."/phpunit/"))); -- 2.30.2