Page MenuHomePhabricator

D14430.id34869.diff
No OneTemporary

D14430.id34869.diff

diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -89,6 +89,7 @@
'ArcanistDuplicateKeysInArrayXHPASTLinterRule' => 'lint/linter/xhpast/rules/ArcanistDuplicateKeysInArrayXHPASTLinterRule.php',
'ArcanistDuplicateSwitchCaseXHPASTLinterRule' => 'lint/linter/xhpast/rules/ArcanistDuplicateSwitchCaseXHPASTLinterRule.php',
'ArcanistDynamicDefineXHPASTLinterRule' => 'lint/linter/xhpast/rules/ArcanistDynamicDefineXHPASTLinterRule.php',
+ 'ArcanistElixirDogmaLinter' => 'lint/linter/ArcanistElixirDogmaLinter.php',
'ArcanistElseIfUsageXHPASTLinterRule' => 'lint/linter/xhpast/rules/ArcanistElseIfUsageXHPASTLinterRule.php',
'ArcanistEmptyFileXHPASTLinterRule' => 'lint/linter/xhpast/rules/ArcanistEmptyFileXHPASTLinterRule.php',
'ArcanistEmptyStatementXHPASTLinterRule' => 'lint/linter/xhpast/rules/ArcanistEmptyStatementXHPASTLinterRule.php',
@@ -283,6 +284,7 @@
'ArcanistXMLLinterTestCase' => 'lint/linter/__tests__/ArcanistXMLLinterTestCase.php',
'ArcanistXUnitTestResultParser' => 'unit/parser/ArcanistXUnitTestResultParser.php',
'CSharpToolsTestEngine' => 'unit/engine/CSharpToolsTestEngine.php',
+ 'ExunitTestEngine' => 'unit/engine/ExunitTestEngine.php',
'NoseTestEngine' => 'unit/engine/NoseTestEngine.php',
'PhpunitTestEngine' => 'unit/engine/PhpunitTestEngine.php',
'PhpunitTestEngineTestCase' => 'unit/engine/__tests__/PhpunitTestEngineTestCase.php',
@@ -378,6 +380,7 @@
'ArcanistDuplicateKeysInArrayXHPASTLinterRule' => 'ArcanistXHPASTLinterRule',
'ArcanistDuplicateSwitchCaseXHPASTLinterRule' => 'ArcanistXHPASTLinterRule',
'ArcanistDynamicDefineXHPASTLinterRule' => 'ArcanistXHPASTLinterRule',
+ 'ArcanistElixirDogmaLinter' => 'ArcanistExternalLinter',
'ArcanistElseIfUsageXHPASTLinterRule' => 'ArcanistXHPASTLinterRule',
'ArcanistEmptyFileXHPASTLinterRule' => 'ArcanistXHPASTLinterRule',
'ArcanistEmptyStatementXHPASTLinterRule' => 'ArcanistXHPASTLinterRule',
@@ -572,6 +575,7 @@
'ArcanistXMLLinterTestCase' => 'ArcanistLinterTestCase',
'ArcanistXUnitTestResultParser' => 'Phobject',
'CSharpToolsTestEngine' => 'XUnitTestEngine',
+ 'ExunitTestEngine' => 'ArcanistUnitTestEngine',
'NoseTestEngine' => 'ArcanistUnitTestEngine',
'PhpunitTestEngine' => 'ArcanistUnitTestEngine',
'PhpunitTestEngineTestCase' => 'PhutilTestCase',
diff --git a/src/lint/linter/ArcanistElixirDogmaLinter.php b/src/lint/linter/ArcanistElixirDogmaLinter.php
new file mode 100644
--- /dev/null
+++ b/src/lint/linter/ArcanistElixirDogmaLinter.php
@@ -0,0 +1,80 @@
+<?php
+
+final class ArcanistElixirDogmaLinter extends ArcanistExternalLinter {
+
+ public function getInfoName() {
+ return 'ElixirDogma';
+ }
+
+ public function getInfoURI() {
+ return 'https://github.com/lpil/dogma';
+ }
+
+ public function getInfoDescription() {
+ return pht('A code style linter for Elixir, powered by shame.');
+ }
+
+ public function getLinterName() {
+ return 'ELIXIRDOGMA';
+ }
+
+ public function getLinterConfigurationName() {
+ return 'elixirdogma';
+ }
+
+ public function getDefaultBinary() {
+ return 'mix';
+ }
+
+ protected function getMandatoryFlags() {
+ return array('dogma', '--noerrors', '--format=flycheck');
+ }
+
+ public function getInstallInstructions() {
+ return pht(
+ 'Install dogma by adding it as a dependency to your deps and
+ executing mix deps.get');
+ }
+
+ public function shouldExpectCommandErrors() {
+ return false;
+ }
+
+ protected function canCustomizeLintSeverities() {
+ return false;
+ }
+
+ protected function parseLinterOutput($path, $err, $stdout, $stderr) {
+ $lines = phutil_split_lines($stdout, false);
+
+ $messages = array();
+ foreach ($lines as $line) {
+ $matches = explode(':', $line, 5);
+
+ if (count($matches) === 5) {
+ $message = new ArcanistLintMessage();
+ $message->setPath($path);
+ $message->setLine($matches[1]);
+ $message->setChar($matches[2]);
+ $message->setCode($this->getLinterName());
+ $message->setName($this->getLinterName());
+ $message->setDescription(ucfirst(trim($matches[4])));
+ $message->setSeverity($this->getSeverity(ucfirst(trim($matches[3]))));
+
+ $messages[] = $message;
+ }
+ }
+
+ return $messages;
+ }
+
+ private function getSeverity($identifier) {
+ switch ($identifier) {
+ case 'W':
+ return ArcanistLintSeverity::SEVERITY_WARNING;
+ case 'E':
+ return ArcanistLintSeverity::SEVERITY_ERROR;
+ }
+ return ArcanistLintSeverity::SEVERITY_ADVICE;
+ }
+}
diff --git a/src/unit/engine/ExunitTestEngine.php b/src/unit/engine/ExunitTestEngine.php
new file mode 100644
--- /dev/null
+++ b/src/unit/engine/ExunitTestEngine.php
@@ -0,0 +1,57 @@
+<?php
+
+/**
+ * Very basic 'mix test' unit test engine wrapper.
+ *
+ * It requires the use of the junit_formatter to produce the xml report.
+ * Refer to https://hex.pm/packages/junit_formatter
+ *
+ * Cover reporting is not supported yet.
+ *
+ * Note: When using mix configurations you likely want to execute the
+ * unit tests with the correct environment, e.g. `MIX_ENV=test arc unit`
+ */
+final class ExunitTestEngine extends ArcanistUnitTestEngine {
+
+ private $projectRoot;
+
+ public function run() {
+ $working_copy = $this->getWorkingCopy();
+ $this->projectRoot = $working_copy->getProjectRoot();
+
+ // this is the standard report location when using mix test
+ $junit_file = $this->projectRoot.'/_build/test/test-junit-report.xml';
+ $cover_tmp = new TempFile();
+
+ $future = $this->buildTestFuture($junit_file, $cover_tmp);
+ list($err, $stdout, $stderr) = $future->resolve();
+
+ if (!Filesystem::pathExists($junit_file)) {
+ throw new CommandException(
+ pht('Command failed with error #%s!', $err),
+ $future->getCommand(),
+ $err,
+ $stdout,
+ $stderr);
+ }
+
+ return $this->parseTestResults($junit_file, $cover_tmp);
+ }
+
+ public function buildTestFuture($junit_tmp, $cover_tmp) {
+ $paths = $this->getPaths();
+
+ $cmd_line = csprintf('mix test --junit');
+
+ return new ExecFuture('%C', $cmd_line);
+ }
+
+ public function parseTestResults($junit_tmp, $cover_tmp) {
+ $parser = new ArcanistXUnitTestResultParser();
+ $results = $parser->parseTestResults(
+ Filesystem::readFile($junit_tmp));
+
+ return $results;
+ }
+
+}

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 9, 8:52 PM (1 w, 18 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6732514
Default Alt Text
D14430.id34869.diff (6 KB)

Event Timeline