~ubuntu-branches/ubuntu/wily/phabricator/wily

« back to all changes in this revision

Viewing changes to src/unit/engine/ArcanistUnitTestEngine.php

  • Committer: Package Import Robot
  • Author(s): Richard Sellam
  • Date: 2014-11-01 23:20:06 UTC
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: package-import@ubuntu.com-20141101232006-mvlnp0cil67tsboe
Tags: upstream-0~git20141101/arcanist
Import upstream version 0~git20141101, component arcanist

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
 
 
3
/**
 
4
 * Manages unit test execution.
 
5
 */
 
6
abstract class ArcanistUnitTestEngine {
 
7
 
 
8
  private $workingCopy;
 
9
  private $paths;
 
10
  private $arguments = array();
 
11
  protected $diffID;
 
12
  private $enableAsyncTests;
 
13
  private $enableCoverage;
 
14
  private $runAllTests;
 
15
  protected $renderer;
 
16
 
 
17
 
 
18
  public function setRunAllTests($run_all_tests) {
 
19
    if (!$this->supportsRunAllTests() && $run_all_tests) {
 
20
      $class = get_class($this);
 
21
      throw new Exception(
 
22
        "Engine '{$class}' does not support --everything.");
 
23
    }
 
24
 
 
25
    $this->runAllTests = $run_all_tests;
 
26
    return $this;
 
27
  }
 
28
 
 
29
  public function getRunAllTests() {
 
30
    return $this->runAllTests;
 
31
  }
 
32
 
 
33
  protected function supportsRunAllTests() {
 
34
    return false;
 
35
  }
 
36
 
 
37
  final public function __construct() {}
 
38
 
 
39
  public function setConfigurationManager(
 
40
    ArcanistConfigurationManager $configuration_manager) {
 
41
    $this->configurationManager = $configuration_manager;
 
42
    return $this;
 
43
  }
 
44
 
 
45
  public function getConfigurationManager() {
 
46
    return $this->configurationManager;
 
47
  }
 
48
 
 
49
  final public function setWorkingCopy(
 
50
    ArcanistWorkingCopyIdentity $working_copy) {
 
51
 
 
52
    // TODO: Remove this once ArcanistBaseUnitTestEngine is gone.
 
53
    if ($this instanceof ArcanistBaseUnitTestEngine) {
 
54
      phutil_deprecated(
 
55
        'ArcanistBaseUnitTestEngine',
 
56
        'You should extend from `ArcanistUnitTestEngine` instead.');
 
57
    }
 
58
 
 
59
    $this->workingCopy = $working_copy;
 
60
    return $this;
 
61
  }
 
62
 
 
63
  final public function getWorkingCopy() {
 
64
    return $this->workingCopy;
 
65
  }
 
66
 
 
67
  final public function setPaths(array $paths) {
 
68
    $this->paths = $paths;
 
69
    return $this;
 
70
  }
 
71
 
 
72
  final public function getPaths() {
 
73
    return $this->paths;
 
74
  }
 
75
 
 
76
  final public function setArguments(array $arguments) {
 
77
    $this->arguments = $arguments;
 
78
    return $this;
 
79
  }
 
80
 
 
81
  final public function getArgument($key, $default = null) {
 
82
    return idx($this->arguments, $key, $default);
 
83
  }
 
84
 
 
85
  final public function setEnableAsyncTests($enable_async_tests) {
 
86
    $this->enableAsyncTests = $enable_async_tests;
 
87
    return $this;
 
88
  }
 
89
 
 
90
  final public function getEnableAsyncTests() {
 
91
    return $this->enableAsyncTests;
 
92
  }
 
93
 
 
94
  final public function setEnableCoverage($enable_coverage) {
 
95
    $this->enableCoverage = $enable_coverage;
 
96
    return $this;
 
97
  }
 
98
 
 
99
  final public function getEnableCoverage() {
 
100
    return $this->enableCoverage;
 
101
  }
 
102
 
 
103
  public function setRenderer(ArcanistUnitRenderer $renderer) {
 
104
    $this->renderer = $renderer;
 
105
    return $this;
 
106
  }
 
107
 
 
108
  abstract public function run();
 
109
 
 
110
  /**
 
111
   * Modify the return value of this function in the child class, if you do
 
112
   * not need to echo the test results after all the tests have been run. This
 
113
   * is the case for example when the child class prints the tests results
 
114
   * while the tests are running.
 
115
   */
 
116
  public function shouldEchoTestResults() {
 
117
    return true;
 
118
  }
 
119
 
 
120
}