Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
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
project
drupal
Commits
08eeef15
Commit
08eeef15
authored
11 years ago
by
Angie Byron
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#2132441
by chx, eliza411: Run-tests.sh --module is broken.
parent
402a3cae
No related branches found
No related tags found
2 merge requests
!7452
Issue #1797438. HTML5 validation is preventing form submit and not fully...
,
!789
Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
core/modules/simpletest/simpletest.module
+37
-15
37 additions, 15 deletions
core/modules/simpletest/simpletest.module
core/scripts/run-tests.sh
+10
-20
10 additions, 20 deletions
core/scripts/run-tests.sh
with
47 additions
and
35 deletions
core/modules/simpletest/simpletest.module
+
37
−
15
View file @
08eeef15
...
...
@@ -419,6 +419,10 @@ function simpletest_log_read($test_id, $prefix, $test_class, $during_test = FALS
* each module for files matching the PSR-0 standard. Once loaded the test list
* is cached and stored in a static variable.
*
* @param string $module
* Name of a module. If set then only tests belonging to this module are
* returned.
*
* @return
* An array of tests keyed with the groups specified in each of the tests
* getInfo() method and then keyed by the test class. An example of the array
...
...
@@ -434,17 +438,20 @@ function simpletest_log_read($test_id, $prefix, $test_class, $during_test = FALS
* );
* @endcode
*/
function
simpletest_test_get_all
()
{
$groups
=
&
drupal_static
(
__FUNCTION__
);
function
simpletest_test_get_all
(
$module
=
NULL
)
{
$all_groups
=
&
drupal_static
(
__FUNCTION__
);
$cid
=
"simpletest:
$module
"
;
if
(
!
$groups
)
{
if
(
!
isset
(
$all_groups
[
$cid
]))
{
$all_groups
[
$cid
]
=
array
();
$groups
=
&
$all_groups
[
$cid
];
// Make sure that namespaces for disabled modules are registered so that the
// checks below will find them.
simpletest_classloader_register
();
// Load test information from cache if available, otherwise retrieve the
// information from each tests getInfo() method.
if
(
$cache
=
cache
()
->
get
(
'simpletest'
))
{
if
(
$cache
=
cache
()
->
get
(
$cid
))
{
$groups
=
$cache
->
data
;
}
else
{
...
...
@@ -453,6 +460,12 @@ function simpletest_test_get_all() {
$module_data
=
system_rebuild_module_data
();
$all_data
=
$module_data
+
system_rebuild_theme_data
();
$all_data
+=
drupal_system_listing
(
'/\.profile$/'
,
'profiles'
,
'name'
);
// If module is set then we keep only that one module.
if
(
isset
(
$module
))
{
$all_data
=
array
(
$module
=>
$all_data
[
$module
],
);
}
foreach
(
$all_data
as
$name
=>
$data
)
{
// Build directory in which the test files would reside.
$tests_dir
=
DRUPAL_ROOT
.
'/'
.
dirname
(
$data
->
uri
)
.
'/lib/Drupal/'
.
$name
.
'/Tests'
;
...
...
@@ -499,8 +512,8 @@ function simpletest_test_get_all() {
}
// If this test class requires a non-existing module, skip it.
if
(
!
empty
(
$info
[
'dependencies'
]))
{
foreach
(
$info
[
'dependencies'
]
as
$
module
)
{
if
(
!
isset
(
$
module_data
[
$module
]))
{
foreach
(
$info
[
'dependencies'
]
as
$
dependency
)
{
if
(
!
isset
(
$
dependency_data
[
$dependency
]))
{
continue
2
;
}
}
...
...
@@ -518,10 +531,10 @@ function simpletest_test_get_all() {
// Allow modules extending core tests to disable originals.
drupal_alter
(
'simpletest'
,
$groups
);
cache
()
->
set
(
'simpletest'
,
$groups
);
cache
()
->
set
(
$cid
,
$groups
);
}
}
return
$groups
;
return
$
all_
groups
[
$cid
]
;
}
/**
...
...
@@ -722,17 +735,26 @@ function simpletest_library_info() {
}
/**
* Get PHPUnit Classes
* Get
s
PHPUnit Classes
.
*
* @param bool $name_only
* If TRUE, returns a flat array of class names only.
* @param string $module
* Name of a module. If set then only tests belonging to this module is
* returned.
*
* @return array
* Returns an array of test classes.
*/
function
simpletest_phpunit_get_available_tests
()
{
function
simpletest_phpunit_get_available_tests
(
$module
=
NULL
)
{
// Try to load the class names array from cache.
if
(
$cache
=
\Drupal
::
cache
()
->
get
(
'simpletest_phpunit'
))
{
$cid
=
'simpletest_phpunit:'
.
$module
;
if
(
$cache
=
\Drupal
::
cache
()
->
get
(
$cid
))
{
$test_classes
=
$cache
->
data
;
}
else
{
if
(
$module
)
{
$prefix
=
'Drupal\\'
.
$module
.
'\\'
;
$n
=
strlen
(
$prefix
);
}
// If there was no cached data available we have to find the tests.
// Load the PHPUnit configuration file, which tells us where to find the
// tests.
...
...
@@ -750,13 +772,13 @@ function simpletest_phpunit_get_available_tests() {
}
$name
=
get_class
(
$test
);
if
(
!
array_key_exists
(
$name
,
$test_classes
))
{
if
(
!
array_key_exists
(
$name
,
$test_classes
)
&&
(
!
$module
||
substr
(
$name
,
0
,
$n
)
==
$prefix
)
)
{
$test_classes
[
$name
]
=
$test
->
getInfo
();
}
}
// Since we have recalculated, we now need to store the new data into cache.
\Drupal
::
cache
()
->
set
(
'simpletest_phpunit'
,
$test_classes
);
\Drupal
::
cache
()
->
set
(
$cid
,
$test_classes
);
}
return
$test_classes
;
...
...
This diff is collapsed.
Click to expand it.
core/scripts/run-tests.sh
+
10
−
20
View file @
08eeef15
...
...
@@ -205,7 +205,7 @@ function simpletest_script_parse_args() {
'php'
=>
''
,
'concurrency'
=>
1,
'all'
=>
FALSE,
'module'
=>
FALSE
,
'module'
=>
NULL
,
'class'
=>
FALSE,
'file'
=>
FALSE,
'color'
=>
FALSE,
...
...
@@ -330,6 +330,10 @@ function simpletest_script_init($server_software) {
/
**
*
Get all available tests from simpletest and PHPUnit.
*
*
@param string
$module
*
Name of a module. If
set
then
only tests belonging to this module are
*
returned.
*
*
@return
*
An array of tests keyed with the
groups
specified
in
each of the tests
*
getInfo
()
method and
then
keyed by the
test
class. An example of the array
...
...
@@ -345,9 +349,9 @@ function simpletest_script_init($server_software) {
*
)
;
*
@endcode
*
/
function
simpletest_script_get_all_tests
()
{
$tests
=
simpletest_test_get_all
()
;
$tests
[
'PHPUnit'
]
=
simpletest_phpunit_get_available_tests
()
;
function
simpletest_script_get_all_tests
(
$module
=
NULL
)
{
$tests
=
simpletest_test_get_all
(
$module
)
;
$tests
[
'PHPUnit'
]
=
simpletest_phpunit_get_available_tests
(
$module
)
;
return
$tests
;
}
...
...
@@ -626,8 +630,8 @@ function simpletest_script_get_test_list() {
global
$args
;
$test_list
=
array
()
;
if
(
$args
[
'all'
])
{
$groups
=
simpletest_script_get_all_tests
()
;
if
(
$args
[
'all'
]
||
$args
[
'module'
]
)
{
$groups
=
simpletest_script_get_all_tests
(
$args
[
'module'
]
)
;
$all_tests
=
array
()
;
foreach
(
$groups
as
$group
=>
$tests
)
{
$all_tests
=
array_merge
(
$all_tests
, array_keys
(
$tests
))
;
...
...
@@ -640,20 +644,6 @@ function simpletest_script_get_test_list() {
$test_list
[]
=
$class_name
;
}
}
elseif
(
$args
[
'module'
])
{
$modules
=
drupal_system_listing
(
'/^'
.
DRUPAL_PHP_FUNCTION_PATTERN
.
'\.module$/'
,
'modules'
,
'name'
, 0
)
;
foreach
(
$args
[
'test_names'
]
as
$module
)
{
// PSR-0 only.
$dir
=
dirname
(
$modules
[
$module
]
->uri
)
.
"/lib/Drupal/
$module
/Tests"
;
$files
=
file_scan_directory
(
$dir
,
'@\.php$@'
, array
(
'key'
=>
'name'
,
'recurse'
=>
TRUE,
))
;
foreach
(
$files
as
$test
=>
$file
)
{
$test_list
[]
=
"Drupal
\\
$module
\\
Tests
\\
$test
"
;
}
}
}
elseif
(
$args
[
'file'
])
{
// Extract
test
case
class names from specified files.
foreach
(
$args
[
'test_names'
]
as
$file
)
{
...
...
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