Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal-3515404
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Issue forks
drupal-3515404
Commits
6e60f0b5
Verified
Commit
6e60f0b5
authored
4 months ago
by
Dave Long
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3483931
by mondrake: [CI] Use testdox and colors in tests spawned by run-tests.sh
parent
21e720a9
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
core/lib/Drupal/Core/Test/PhpUnitTestRunner.php
+27
-6
27 additions, 6 deletions
core/lib/Drupal/Core/Test/PhpUnitTestRunner.php
core/scripts/run-tests.sh
+4
-2
4 additions, 2 deletions
core/scripts/run-tests.sh
with
31 additions
and
8 deletions
core/lib/Drupal/Core/Test/PhpUnitTestRunner.php
+
27
−
6
View file @
6e60f0b5
...
...
@@ -9,6 +9,8 @@
use
Symfony\Component\Process\PhpExecutableFinder
;
use
Symfony\Component\Process\Process
;
// cspell:ignore testdox
/**
* Run PHPUnit-based tests.
*
...
...
@@ -100,16 +102,24 @@ public function phpUnitCommand(): string {
* A fully qualified test class name.
* @param string $log_junit_file_path
* A filepath to use for PHPUnit's --log-junit option.
* @param int $status
* @param int
|null
$status
* (optional) The exit status code of the PHPUnit process will be assigned
* to this variable.
* @param string[] $output
* @param string[]
|null
$output
* (optional) The output by running the phpunit command. If provided, this
* array will contain the lines output by the command.
* @param bool $colors
* (optional) Whether to use colors in output. Defaults to FALSE.
*
* @internal
*/
protected
function
runCommand
(
string
$test_class_name
,
string
$log_junit_file_path
,
?int
&
$status
=
NULL
,
?array
&
$output
=
NULL
):
void
{
protected
function
runCommand
(
string
$test_class_name
,
string
$log_junit_file_path
,
?int
&
$status
=
NULL
,
?array
&
$output
=
NULL
,
bool
$colors
=
FALSE
,
):
void
{
global
$base_url
;
// Setup an environment variable containing the database connection so that
// functional tests can connect to the database.
...
...
@@ -130,9 +140,13 @@ protected function runCommand(string $test_class_name, string $log_junit_file_pa
// Build the command line for the PHPUnit CLI invocation.
$command
=
[
$phpunit_bin
,
'--testdox'
,
'--log-junit'
,
$log_junit_file_path
,
];
if
(
$colors
)
{
$command
[]
=
'--colors=always'
;
}
// If the deprecation handler bridge is active, we need to fail when there
// are deprecations that get reported (i.e. not ignored or expected).
...
...
@@ -159,9 +173,11 @@ protected function runCommand(string $test_class_name, string $log_junit_file_pa
* The test run object.
* @param string $test_class_name
* A fully qualified test class name.
* @param int $status
* @param int
|null
$status
* (optional) The exit status code of the PHPUnit process will be assigned
* to this variable.
* @param bool $colors
* (optional) Whether to use colors in output. Defaults to FALSE.
*
* @return array
* The parsed results of PHPUnit's JUnit XML output, in the format of
...
...
@@ -169,11 +185,16 @@ protected function runCommand(string $test_class_name, string $log_junit_file_pa
*
* @internal
*/
public
function
execute
(
TestRun
$test_run
,
string
$test_class_name
,
?int
&
$status
=
NULL
):
array
{
public
function
execute
(
TestRun
$test_run
,
string
$test_class_name
,
?int
&
$status
=
NULL
,
bool
$colors
=
FALSE
,
):
array
{
$log_junit_file_path
=
$this
->
xmlLogFilePath
(
$test_run
->
id
());
// Store output from our test run.
$output
=
[];
$this
->
runCommand
(
$test_class_name
,
$log_junit_file_path
,
$status
,
$output
);
$this
->
runCommand
(
$test_class_name
,
$log_junit_file_path
,
$status
,
$output
,
$colors
);
if
(
$status
==
TestStatus
::
PASS
)
{
return
JUnitConverter
::
xmlToRows
(
$test_run
->
id
(),
$log_junit_file_path
);
...
...
This diff is collapsed.
Click to expand it.
core/scripts/run-tests.sh
+
4
−
2
View file @
6e60f0b5
...
...
@@ -829,9 +829,11 @@ function simpletest_script_execute_batch(TestRunResultsStorageInterface $test_ru
*
Run a PHPUnit-based test.
*
/
function
simpletest_script_run_phpunit
(
TestRun
$test_run
,
$class
)
{
global
$args
;
$runner
=
PhpUnitTestRunner::create
(
\D
rupal::getContainer
())
;
$start
=
microtime
(
TRUE
)
;
$results
=
$runner
->execute
(
$test_run
,
$class
,
$status
)
;
$results
=
$runner
->execute
(
$test_run
,
$class
,
$status
,
$args
[
'color'
]
)
;
$time
=
microtime
(
TRUE
)
-
$start
;
$runner
->processPhpUnitResults
(
$test_run
,
$results
)
;
...
...
@@ -1369,7 +1371,7 @@ function simpletest_script_format_result($result) {
if
(
$args
[
'non-html'
])
{
$message
=
Html::decodeEntities
(
$message
)
;
}
$lines
=
explode
(
"
\n
"
,
wordwrap
(
$message
)
, 76
)
;
$lines
=
explode
(
"
\n
"
,
$message
)
;
foreach
(
$lines
as
$line
)
{
echo
"
$line
\n
"
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment