Indefero

Indefero Commit Details


Date:2010-06-29 09:00:53 (14 years 5 months ago)
Author:Thomas Keller
Branch:develop, feature-issue_links, feature.better-home, feature.content-md5, feature.diff-whitespace, feature.download-md5, feature.issue-links, feature.issue-of-others, feature.issue-summary, feature.search-filter, feature.webrepos, feature.wiki-default-page, master, release-1.1, release-1.2, release-1.3
Commit:0ad7f478850ef41ee112c8ac469a3c980068fb73
Parents: d2f0bac907e82ee394ada3db603354223cbc317f
Message:first, incomplete version of a basic monotone test driver

Changes:

File differences

src/IDF/Tests/TestMonotone.php
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<?php
/* -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
# ***** BEGIN LICENSE BLOCK *****
# This file is part of InDefero, an open source project management application.
# Copyright (C) 2010 CĂ©ondo Ltd and contributors.
#
# InDefero is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# InDefero is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
# ***** END LICENSE BLOCK ***** */
require_once("simpletest/autorun.php");
/**
* Test the monotone class.
*/
class IDF_Tests_TestMonotone extends UnitTestCase
{
private $tmpdir, $dbfile;
private function mtnCall($args, $stdin = null, $dir = null)
{
$cmdline = array("mtn",
"--confdir", $this->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);
}
}

Archive Download the corresponding diff file

Page rendered in 0.08449s using 13 queries.