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
493a9ac6
Commit
493a9ac6
authored
16 years ago
by
Dries Buytaert
Browse files
Options
Downloads
Patches
Plain Diff
- Patch
#254166
by pwolanin: script improvements.
parent
25a5bf9f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
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
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scripts/run-functional-tests.sh
+169
-17
169 additions, 17 deletions
scripts/run-functional-tests.sh
with
169 additions
and
17 deletions
scripts/run-functional-tests.sh
+
169
−
17
View file @
493a9ac6
...
@@ -4,30 +4,93 @@
...
@@ -4,30 +4,93 @@
/
**
/
**
*
@file
*
@file
*
This script can be run with browser or from
command
line.
*
This script runs Drupal tests from
command
line.
*
You can provide class names of the tests you wish to run.
*
You can provide
groups
or class names of the tests you wish to run.
*
When this script is run from browser you can
select
which reporter to use html or xml.
*
For example: php scripts/run-functional-tests.sh Profile
*
For
command
line: php run_functional_tests.php SearchMatchTest,ProfileModuleTestSingle
*
If no arguments are provided, the
help
text will print.
*
For browser: http://yoursite.com/sites/all/modules/simpletest/run_all_tests.php?include
=
SearchMatchTest,ProfileModuleTestSingle&reporter
=
html
*
If none of these two options are provided all tests will be run.
*
/
*
/
$tests
=
NULL
;
$reporter
=
'text'
;
$reporter
=
'text'
;
$test_names
=
array
()
;
$host
=
'localhost'
;
$host
=
'localhost'
;
$path
=
''
;
$path
=
''
;
array_shift
(
$_SERVER
[
'argv'
])
;
// throw away script name
$script
=
basename
(
array_shift
(
$_SERVER
[
'argv'
]))
;
if
(
in_array
(
'--help'
,
$_SERVER
[
'argv'
])
||
empty
(
$_SERVER
[
'argv'
]))
{
echo
<<<
EOF
Run Drupal tests from the shell.
Usage:
{
$script
}
[
OPTIONS] <tests>
Example:
{
$script
}
Profile
All arguments are long options.
--help
Print this page.
--clean
Cleans up database tables or directories from previous, failed,
tests and
then
exits
(
no tests are run
)
.
--url
Immediately preceeds a URL to
set
the host and path. You will
need this parameter
if
Drupal is
in
a subdirectory on your
localhost and you have not
set
\$
base_url
in
settings.php.
--reporter
Immediatly preceeds the name of the output reporter to use. This
Defaults to
"text"
,
while
other options include
"xml"
and
"html"
.
--all
Run all available tests.
--class
Run tests identified by speficic class names.
<test1>[,<test2>[,<test3> ...]]
One or more tests to be run. By default, these are interpreted
as the names of
test groups
as shown at ?q
=
admin/build/testing.
These group names typically correspond to module names like
"User"
or
"Profile"
or
"System"
, but there is also a group
"XML-RPC"
.
If
--class
is specified
then
these are interpreted as the names of
specific
test
classes whose
test
methods will be run. Tests must
be separated by commas. Ignored
if
--all
is specified.
To run this script you will normally invoke it from the root directory of your
Drupal installation as
php ./scripts/
{
$script
}
\n
EOF
;
exit
;
}
$clean
=
FALSE
;
$all
=
FALSE
;
$class_names
=
FALSE
;
$test_names
=
array
()
;
while
(
$param
=
array_shift
(
$_SERVER
[
'argv'
]))
{
while
(
$param
=
array_shift
(
$_SERVER
[
'argv'
]))
{
switch
(
$param
)
{
switch
(
$param
)
{
case
'--url'
:
case
'--url'
:
$url
=
array_shift
(
$_SERVER
[
'argv'
]
);
$url
=
array_shift
(
$_SERVER
[
'argv'
]
);
$parse
=
parse_url
(
$url
)
;
$parsed
=
parse_url
(
$url
)
;
$host
=
$parse
[
'host'
]
;
$host
=
$parsed
[
'host'
]
;
$path
=
$parse
[
'path'
]
;
$path
=
$parsed
[
'path'
]
;
break
;
case
'--all'
:
$all
=
TRUE
;
break
;
case
'--class'
:
$class_names
=
TRUE
;
break
;
case
'--clean'
:
$clean
=
TRUE
;
break
;
case
'--reporter'
:
$reporter
=
array_shift
(
$_SERVER
[
'argv'
]
);
if
(!
in_array
(
$reporter
, array
(
"text"
,
"xml"
,
"html"
)))
{
$reporter
=
"text"
;
}
break
;
break
;
default:
default:
$tests
=
explode
(
','
,
$param
)
;
$test
_name
s
+
=
explode
(
','
,
$param
)
;
break
;
break
;
}
}
}
}
...
@@ -46,13 +109,102 @@
...
@@ -46,13 +109,102 @@
require_once
'./includes/bootstrap.inc'
;
require_once
'./includes/bootstrap.inc'
;
drupal_bootstrap
(
DRUPAL_BOOTSTRAP_FULL
)
;
drupal_bootstrap
(
DRUPAL_BOOTSTRAP_FULL
)
;
//load simpletest files
if
(!
module_exists
(
'simpletest'
))
{
simpletest_load
()
;
echo
(
"ERROR: The simpletest module must be enabled before this script can run.
\n
"
)
;
exit
;
}
if
(
$clean
)
{
// Clean up left-over
times
and directories.
simpletest_clean_environment
()
;
// Get the status messages and print them.
$messages
=
array_pop
(
drupal_get_messages
(
'status'
))
;
foreach
(
$messages
as
$text
)
{
echo
(
"- "
.
$text
.
"
\n
"
)
;
}
exit
;
}
// Run tests as user
#1.
$GLOBALS
[
'user'
]
=
user_load
(
1
)
;
//Load simpletest files
$total_test
=
&simpletest_get_total_test
()
;
$test_instances
=
$total_test
->getTestInstances
()
;
if
(
$all
)
{
$test_list
=
NULL
;
}
else
{
if
(
$class_names
)
{
$test_list
=
_run_tests_check_classes
(
$test_names
,
$test_instances
)
;
}
else
{
$test_list
=
_run_tests_find_classes
(
$test_names
,
$test_instances
)
;
}
}
if
(
empty
(
$test_list
)
&&
!
$all
)
{
echo
(
"ERROR: No valid tests were specified.
\n
"
)
;
exit
;
}
// If not
in
'safe mode'
, increase the maximum execution
time
:
// If not
in
'safe mode'
, increase the maximum execution
time
:
if
(!
ini_get
(
'safe_mode'
))
{
if
(!
ini_get
(
'safe_mode'
))
{
set_time_limit
(
360
)
;
set_time_limit
(
360
)
;
}
}
simpletest_run_tests
(
$tests
,
$reporter
)
;
// Tell the user about what tests are to be run.
?>
if
(!
$all
&&
$reporter
==
'text'
)
{
echo
(
"Tests to be run:
\n
"
)
;
foreach
(
$test_list
as
$name
)
{
echo
(
"- "
.
$name
.
"
\n
"
)
;
}
echo
(
"
\n
"
)
;
}
simpletest_run_tests
(
array_keys
(
$test_list
)
,
$reporter
)
;
// Utility functions:
/
**
*
Check that each class name exists as a
test
,
return
the list of valid ones.
*
/
function
_run_tests_check_classes
(
$test_names
,
$test_instances
)
{
$test_list
=
array
()
;
$test_names
=
array_flip
(
$test_names
)
;
foreach
(
$test_instances
as
$group_test
)
{
$tests
=
$group_test
->getTestInstances
()
;
foreach
(
$tests
as
$test
)
{
$class
=
get_class
(
$test
)
;
$info
=
$test
->getInfo
()
;
if
(
isset
(
$test_names
[
$class
]))
{
$test_list
[
$class
]
=
$info
[
'name'
]
;
}
}
}
return
$test_list
;
}
/
**
*
Check that each group name exists,
return
the list of class
in
valid groups.
*
/
function
_run_tests_find_classes
(
$test_names
, &
$test_instances
)
{
$test_list
=
array
()
;
$test_names
=
array_flip
(
$test_names
)
;
uasort
(
$test_instances
,
'simpletest_compare_instances'
)
;
foreach
(
$test_instances
as
$group_test
)
{
$group
=
$group_test
->getLabel
()
;
if
(
isset
(
$test_names
[
$group
]))
{
$tests
=
$group_test
->getTestInstances
()
;
foreach
(
$tests
as
$test
)
{
$info
=
$test
->getInfo
()
;
$test_list
[
get_class
(
$test
)]
=
$info
[
'name'
]
;
}
}
}
return
$test_list
;
}
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