tmpdir, "--db", $this->dbfile, "--norc", "--timestamps"); $cmdline = array_merge($cmdline, $args); $descriptorspec = array( 0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => array("file", "{$this->tmpdir}/mtn-errors", "a") ); $pipes = array(); $process = proc_open(implode(" ", $cmdline), $descriptorspec, $pipes, empty($dir) ? $this->tmpdir : $dir); if (!is_resource($process)) { throw new Exception("could not create process"); } if (!empty($stdin)) { fwrite($pipes[0], $stdin); fclose($pipes[0]); } $stdout = stream_get_contents($pipes[1]); fclose($pipes[1]); $ret = proc_close($process); if ($ret != 0) { throw new Exception( "call ended with a non-zero error code (complete cmdline was: ". implode(" ", $cmdline).")" ); } return $stdout; } public function __construct() { parent::__construct("Test the monotone class."); $this->tmpdir = sys_get_temp_dir() . "/mtn-test"; echo "test root is {$this->tmpdir}\n"; $this->dbfile = "{$this->tmpdir}/test.mtn"; } private static function deleteRecursive($dirname) { if (is_dir($dirname)) $dir_handle=opendir($dirname); while ($file = readdir($dir_handle)) { if ($file!="." && $file!="..") { if (!is_dir($dirname."/".$file)) { unlink ($dirname."/".$file); continue; } self::deleteRecursive($dirname."/".$file); } } closedir($dir_handle); rmdir($dirname); return true; } public function setUp() { if (is_dir($this->tmpdir)) { self::deleteRecursive($this->tmpdir); } mkdir($this->tmpdir); $this->mtnCall(array("db", "init")); $this->mtnCall(array("genkey", "test@test.de"), "\n\n"); $workspaceRoot = "{$this->tmpdir}/test-workspace"; mkdir($workspaceRoot); $this->mtnCall(array("setup", "-b", "testbranch", "blafoo"), null, $workspaceRoot); file_put_contents("$workspaceRoot/foo", "blafoo"); $this->mtnCall(array("add", "foo"), null, $workspaceRoot); $this->mtnCall(array("commit", "-m", "initial"), null, $workspaceRoot); file_put_contents("$workspaceRoot/foo", "bla"); file_put_contents("$workspaceRoot/bar", "blafoo"); $this->mtnCall(array("add", "bar"), null, $workspaceRoot); $this->mtnCall(array("commit", "-m", "second"), null, $workspaceRoot); } public function testBranches() { $this->assertTrue(false); } }