-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for run configuration in Docker and support for Nette T…
- Loading branch information
Showing
17 changed files
with
272 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
<idea-plugin> | ||
<id>cz.jiripudil.intellij.nette.tester</id> | ||
<name>Nette Tester</name> | ||
<version>2.0.0-beta.4</version> | ||
<version>2.1.0</version> | ||
<vendor email="[email protected]" url="https://jiripudil.cz">Jiří Pudil</vendor> | ||
<resource-bundle>messages.TesterBundle</resource-bundle> | ||
|
||
|
@@ -13,9 +13,11 @@ | |
]]></description> | ||
|
||
<change-notes><![CDATA[ | ||
<h2>2.0.0-beta.4</h2> | ||
<h2>2.1.0</h2> | ||
<ul> | ||
<li>Added support for run line markers</li> | ||
<li>Added run line markers to run TestCase or test methods</li> | ||
<li>Added support for run configuration in Docker</li> | ||
<li>Added support for Nette Tester 2.0</li> | ||
<li>Fixed Compatibility with PHPStorm 2019.2 (<a href="https://github.com/jiripudil/intellij-nette-tester/issues/43">#43</a>)</li> | ||
<li>Fixed bug java.lang.NullPointerException on phpstorm startup (<a href="https://github.com/jiripudil/intellij-nette-tester/issues/45">#45</a>)</li> | ||
</ul> | ||
|
@@ -85,14 +87,15 @@ | |
<extensions defaultExtensionNs="com.intellij"> | ||
<configurationType implementation="cz.jiripudil.intellij.nette.tester.configuration.TesterRunConfigurationType"/> | ||
<runConfigurationProducer implementation="cz.jiripudil.intellij.nette.tester.configuration.TesterRunConfigurationProducer"/> | ||
<runLineMarkerContributor language="PHP" implementationClass="cz.jiripudil.intellij.nette.tester.lineMarker.TesterRunLineMarkerProvider"/> | ||
|
||
<configurationType implementation="cz.jiripudil.intellij.nette.tester.configuration.TesterTestMethodRunConfigurationType"/> | ||
<runConfigurationProducer implementation="cz.jiripudil.intellij.nette.tester.configuration.TesterTestMethodRunConfigurationProducer"/> | ||
<runLineMarkerContributor language="PHP" implementationClass="cz.jiripudil.intellij.nette.tester.lineMarker.TesterMethodRunLineMarkerProvider"/> | ||
|
||
<analyzeStacktraceFilter implementation="cz.jiripudil.intellij.nette.tester.execution.TesterStackTraceFilter"/> | ||
|
||
<runLineMarkerContributor language="PHP" implementationClass="cz.jiripudil.intellij.nette.tester.lineMarker.TesterRunLineMarkerProvider"/> | ||
<runLineMarkerContributor language="PHP" implementationClass="cz.jiripudil.intellij.nette.tester.lineMarker.TesterMethodRunLineMarkerProvider"/> | ||
|
||
<testFinder implementation="cz.jiripudil.intellij.nette.tester.TesterTestFinder"/> | ||
<testCreator language="PHP" implementationClass="cz.jiripudil.intellij.nette.tester.codeGeneration.TesterTestCreator"/> | ||
<internalFileTemplate name="Tester TestCase"/> | ||
|
@@ -105,6 +108,7 @@ | |
id="cz.jiripudil.intellij.nette.tester.projectSettings.TesterConfigurable" | ||
parentId="reference.webide.settings.project.settings.php" | ||
groupWeight="25" | ||
nonDefaultProject="true" | ||
/> | ||
|
||
<localInspection | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
<?php | ||
|
||
use Tester\Runner\OutputHandler; | ||
use Tester\Runner\Runner; | ||
|
||
|
||
$userSetupScript = \getenv('INTELLIJ_NETTE_TESTER_USER_SETUP'); | ||
if ($userSetupScript) { | ||
require_once $userSetupScript; | ||
} | ||
|
||
|
||
final class TeamCityOutputHandler implements OutputHandler | ||
{ | ||
|
||
/** | ||
* @var resource | ||
*/ | ||
private $file; | ||
|
||
|
||
public function __construct($output = 'php://output') | ||
{ | ||
$this->file = \fopen($output, 'w'); | ||
} | ||
|
||
|
||
public function begin(): void | ||
{ | ||
// \fwrite($this->file, $this->message('testCount', array('count' => 0))); | ||
} | ||
|
||
function prepare(\Tester\Runner\Test $test): void | ||
{ | ||
// TODO: Implement prepare() method. | ||
} | ||
|
||
function finish(\Tester\Runner\Test $test): void | ||
{ | ||
$testName = $test->title ?: $test->getFile(); | ||
$result = $test->getResult(); | ||
$message = $test->message; | ||
|
||
$flowId = \md5($testName); | ||
\fwrite($this->file, $this->message('testStarted', array('name' => $testName, 'flowId' => $flowId))); | ||
|
||
if ($result === \Tester\Runner\Test::SKIPPED) { // Runner::SKIPPED, Test::SKIPPED | ||
\fwrite($this->file, $this->message('testIgnored', array('name' => $testName, 'flowId' => $flowId, 'message' => 'Test skipped', 'details' => $message))); | ||
|
||
} elseif ($result === \Tester\Runner\Test::FAILED) { // Runner::FAILED, Test::FAILED | ||
$extraArguments = array(); | ||
if (\preg_match("/^diff \"(.*)\" \"(.*)\"$/m", $message, $matches)) { // Windows build | ||
$expectedFile = \str_replace('""', '"', $matches[1]); | ||
$actualFile = \str_replace('""', '"', $matches[2]); | ||
$extraArguments = array('type' => 'comparisonFailure', 'expectedFile' => $expectedFile, 'actualFile' => $actualFile); | ||
|
||
} elseif (\preg_match("/^diff '?(.*)'? '?(.*)'?$/m", $message, $matches)) { | ||
$expectedFile = \trim($matches[1], "'"); | ||
$actualFile = \trim($matches[2], "'"); | ||
$extraArguments = array('type' => 'comparisonFailure', 'expectedFile' => $expectedFile, 'actualFile' => $actualFile); | ||
|
||
} elseif (\preg_match("/Failed: (.*) should be( equal to)?\s+\.*\s*(.*) in/is", $message, $matches)) { | ||
$expected = $matches[3]; | ||
$actual = $matches[1]; | ||
$extraArguments = array('type' => 'comparisonFailure', 'expected' => $expected, 'actual' => $actual); | ||
} | ||
|
||
$args = \array_merge(array( | ||
'name' => $testName, | ||
'flowId' => $flowId, | ||
'message' => 'Test failed', | ||
'details' => $message, | ||
), $extraArguments); | ||
|
||
\fwrite($this->file, $this->message('testFailed', $args)); | ||
} | ||
|
||
\fwrite($this->file, $this->message('testFinished', array('name' => $testName, 'flowId' => $flowId))); | ||
} | ||
|
||
|
||
public function end(): void | ||
{ | ||
} | ||
|
||
|
||
private function message($messageName, $args): string | ||
{ | ||
$argsPairs = array(); | ||
foreach ($args as $arg => $value) { | ||
$argsPairs[] = \sprintf("%s='%s'", $arg, $this->escape($value)); | ||
} | ||
|
||
return \sprintf( | ||
"##teamcity[%s %s]\n\n", | ||
$messageName, | ||
\implode(' ', $argsPairs) | ||
); | ||
} | ||
|
||
|
||
private function escape($value): string | ||
{ | ||
$replace = array( | ||
"|" => "||", | ||
"'" => "|'", | ||
"\n" => "|n", | ||
"\r" => "|r", | ||
"]" => "|]", | ||
"[" => "|[", | ||
); | ||
|
||
return \strtr($value, $replace); | ||
} | ||
|
||
} | ||
|
||
|
||
/** @var Runner $runner */ | ||
// replace registered output handlers with TC | ||
$runner->outputHandlers = array(); | ||
$runner->outputHandlers[] = new TeamCityOutputHandler(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.