3
final class ArcanistBaseCommitParserTestCase extends ArcanistTestCase {
5
public function testBasics() {
6
// Verify that the very basics of base commit resolution work.
17
'runtime' => 'literal:xyz',
21
public function testResolutionOrder() {
22
// Rules should be resolved in order: args, local, project, global. These
23
// test cases intentionally scramble argument order to test that resolution
24
// order is independent of argument order.
29
'local' => 'literal:n',
30
'project' => 'literal:n',
31
'runtime' => 'literal:y',
32
'user' => 'literal:n',
39
'project' => 'literal:n',
40
'local' => 'literal:y',
41
'user' => 'literal:n',
48
'project' => 'literal:y',
49
'user' => 'literal:n',
56
'user' => 'literal:y',
60
public function testLegacyRule() {
61
// 'global' should translate to 'user'
66
'runtime' => 'arc:global, arc:halt',
67
'local' => 'arc:halt',
68
'project' => 'arc:halt',
69
'user' => 'literal:y',
72
// 'args' should translate to 'runtime'
77
'runtime' => 'arc:project, literal:y',
78
'local' => 'arc:halt',
79
'project' => 'arc:args',
84
public function testHalt() {
85
// 'arc:halt' should halt all processing.
90
'runtime' => 'arc:halt',
91
'local' => 'literal:xyz',
95
public function testYield() {
96
// 'arc:yield' should yield to other rulesets.
101
'runtime' => 'arc:yield, literal:abc',
102
'local' => 'literal:xyz',
105
// This one should return to 'runtime' after exhausting 'local'.
110
'runtime' => 'arc:yield, literal:abc',
111
'local' => 'arc:skip',
115
public function testJump() {
116
// This should resolve to 'abc' without hitting any of the halts.
121
'runtime' => 'arc:project, arc:halt',
122
'local' => 'literal:abc',
123
'project' => 'arc:user, arc:halt',
124
'user' => 'arc:local, arc:halt',
128
public function testJumpReturn() {
129
// After jumping to project, we should return to 'runtime'.
134
'runtime' => 'arc:project, literal:xyz',
135
'local' => 'arc:halt',
137
'user' => 'arc:halt',
141
private function assertCommit($desc, $commit, $rules) {
142
$parser = $this->buildParser();
143
$result = $parser->resolveBaseCommit($rules);
144
$this->assertEqual($commit, $result, $desc);
147
private function buildParser() {
148
// TODO: This is a little hacky because we're using the Arcanist repository
149
// itself to execute tests with, but it should be OK until we get proper
150
// isolation for repository-oriented test cases.
152
$root = dirname(phutil_get_library_root('arcanist'));
153
$working_copy = ArcanistWorkingCopyIdentity::newFromPath($root);
154
$configuration_manager = new ArcanistConfigurationManager();
155
$configuration_manager->setWorkingCopyIdentity($working_copy);
156
$repo = ArcanistRepositoryAPI::newAPIFromConfigurationManager(
157
$configuration_manager);
159
return new ArcanistBaseCommitParser($repo);