Indefero

Indefero Commit Details


Date:2010-06-29 17:42:09 (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:780267978d9c7a9908be888edf8711e297e12289
Parents: 0ad7f478850ef41ee112c8ac469a3c980068fb73
Message:basic test setup works; added tests for isAvailable(), getBranches(), getTags(), inTags(), inBranches(), getTree() and isValidRevision()

Changes:

File differences

src/IDF/Tests/TestMonotone.php
2828
2929
3030
31
31
3232
3333
3434
35
36
3537
3638
3739
......
4749
4850
4951
52
5053
5154
5255
53
56
5457
5558
5659
......
8386
8487
8588
86
8789
90
91
92
93
94
95
96
97
8898
8999
90100
......
127137
128138
129139
130
140
131141
132
142
133143
134144
135145
136146
137
138
139147
140
148
149
150
141151
142152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
143239
144240
145
241
146242
147
243
244
148245
149246
*/
class IDF_Tests_TestMonotone extends UnitTestCase
{
private $tmpdir, $dbfile;
private $tmpdir, $dbfile, $mtnInstance;
private function mtnCall($args, $stdin = null, $dir = null)
{
// if you have an SSH agent running for key caching,
// please disable it
$cmdline = array("mtn",
"--confdir", $this->tmpdir,
"--db", $this->dbfile,
);
$pipes = array();
$dir = !empty($dir) ? $dir : $this->tmpdir;
$process = proc_open(implode(" ", $cmdline),
$descriptorspec,
$pipes,
empty($dir) ? $this->tmpdir : $dir);
$dir);
if (!is_resource($process))
{
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";
set_include_path(get_include_path() . ":../../../pluf-master/src");
require_once("Pluf.php");
Pluf::start(dirname(__FILE__)."/../conf/idf.php");
// Pluf::f() mocking
$GLOBALS['_PX_config']['mtn_repositories'] = "{$this->tmpdir}/%s.mtn";
}
private static function deleteRecursive($dirname)
$workspaceRoot = "{$this->tmpdir}/test-workspace";
mkdir($workspaceRoot);
$this->mtnCall(array("setup", "-b", "testbranch", "blafoo"), null, $workspaceRoot);
$this->mtnCall(array("setup", "-b", "testbranch", "."), null, $workspaceRoot);
file_put_contents("$workspaceRoot/foo", "blafoo");
file_put_contents("$workspaceRoot/foo", "blubber");
$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);
mkdir("$workspaceRoot/subdir");
file_put_contents("$workspaceRoot/subdir/bla", "blabla");
$this->mtnCall(array("add", "-R", "--unknown"), null, $workspaceRoot);
$this->mtnCall(array("commit", "-m", "second"), null, $workspaceRoot);
$rev = $this->mtnCall(array("au", "get_base_revision_id"), null, $workspaceRoot);
$this->mtnCall(array("tag", rtrim($rev), "release-1.0"));
$project = new IDF_Project();
$project->shortname = "test";
$this->mtnInstance = new IDF_Scm_Monotone($project);
}
public function testIsAvailable()
{
$this->assertTrue($this->mtnInstance->isAvailable());
}
public function testGetBranches()
{
$branches = $this->mtnInstance->getBranches();
$this->assertEqual(1, count($branches));
list($key, $value) = each($branches);
$this->assertEqual("h:testbranch", $key);
$this->assertEqual("testbranch", $value);
}
public function testGetTags()
{
$tags = $this->mtnInstance->getTags();
$this->assertEqual(1, count($tags));
list($key, $value) = each($tags);
$this->assertEqual("t:release-1.0", $key);
$this->assertEqual("release-1.0", $value);
}
public function testInBranches()
{
$revOut = $this->mtnCall(array("au", "select", "b:testbranch"));
$revs = preg_split('/\n/', $revOut, -1, PREG_SPLIT_NO_EMPTY);
$branches = $this->mtnInstance->inBranches($revs[0], null);
$this->assertEqual(1, count($branches));
$this->assertEqual("h:testbranch", $branches[0]);
$branches = $this->mtnInstance->inBranches("t:release-1.0", null);
$this->assertEqual(1, count($branches));
$this->assertEqual("h:testbranch", $branches[0]);
}
public function testInTags()
{
$rev = $this->mtnCall(array("au", "select", "t:release-1.0"));
$tags = $this->mtnInstance->inTags(rtrim($rev), null);
$this->assertEqual(1, count($tags));
$this->assertEqual("t:release-1.0", $tags[0]);
// pick the first (root) revisions in this database
$rev = $this->mtnCall(array("au", "roots"));
$tags = $this->mtnInstance->inTags(rtrim($rev), null);
$this->assertEqual(0, count($tags));
}
public function testGetTree()
{
$files = $this->mtnInstance->getTree("t:release-1.0");
$this->assertEqual(3, count($files));
$this->assertEqual("bar", $files[0]->file);
$this->assertEqual("blob", $files[0]->type);
$this->assertEqual(6, $files[0]->size); // "blafoo"
$this->assertEqual("second\n", $files[0]->log);
$this->assertEqual("foo", $files[1]->file);
$this->assertEqual("blob", $files[1]->type);
$this->assertEqual(7, $files[1]->size); // "blubber"
$this->assertEqual("initial\n", $files[1]->log);
$this->assertEqual("subdir", $files[2]->file);
$this->assertEqual("tree", $files[2]->type);
$this->assertEqual(0, $files[2]->size);
$files = $this->mtnInstance->getTree("t:release-1.0", "subdir");
$this->assertEqual(1, count($files));
$this->assertEqual("bla", $files[0]->file);
$this->assertEqual("subdir/bla", $files[0]->fullpath);
$this->assertEqual("blob", $files[0]->type);
$this->assertEqual(6, $files[0]->size); // "blabla"
$this->assertEqual("second\n", $files[0]->log);
}
public function testBranches()
public function testIsValidRevision()
{
$this->assertTrue(false);
$this->assertTrue($this->mtnInstance->isValidRevision("t:release-1.0"));
$this->assertFalse($this->mtnInstance->isValidRevision("abcdef12345"));
}
}

Archive Download the corresponding diff file

Page rendered in 0.08421s using 13 queries.