Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
08eeef15
Commit
08eeef15
authored
Nov 22, 2013
by
webchick
Browse files
Issue
#2132441
by chx, eliza411: Run-tests.sh --module is broken.
parent
402a3cae
Changes
2
Hide whitespace changes
Inline
Side-by-side
core/modules/simpletest/simpletest.module
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
;
...
...
core/scripts/run-tests.sh
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
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment