Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Grpc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tci-gateway-module
Grpc
Commits
c7449166
Commit
c7449166
authored
10 years ago
by
Craig Tiller
Browse files
Options
Downloads
Patches
Plain Diff
PHP unit tests run with run_tests.py
parent
c2e80bfb
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tools/run_tests/run_tests.py
+67
-40
67 additions, 40 deletions
tools/run_tests/run_tests.py
with
67 additions
and
40 deletions
tools/run_tests/run_tests.py
+
67
−
40
View file @
c7449166
...
@@ -20,6 +20,7 @@ class SimpleConfig(object):
...
@@ -20,6 +20,7 @@ class SimpleConfig(object):
def
__init__
(
self
,
config
):
def
__init__
(
self
,
config
):
self
.
build_config
=
config
self
.
build_config
=
config
self
.
maxjobs
=
32
*
multiprocessing
.
cpu_count
()
self
.
maxjobs
=
32
*
multiprocessing
.
cpu_count
()
self
.
allow_hashing
=
(
config
!=
'
gcov
'
)
def
run_command
(
self
,
binary
):
def
run_command
(
self
,
binary
):
return
[
binary
]
return
[
binary
]
...
@@ -32,11 +33,43 @@ class ValgrindConfig(object):
...
@@ -32,11 +33,43 @@ class ValgrindConfig(object):
self
.
build_config
=
config
self
.
build_config
=
config
self
.
tool
=
tool
self
.
tool
=
tool
self
.
maxjobs
=
4
*
multiprocessing
.
cpu_count
()
self
.
maxjobs
=
4
*
multiprocessing
.
cpu_count
()
self
.
allow_hashing
=
False
def
run_command
(
self
,
binary
):
def
run_command
(
self
,
binary
):
return
[
'
valgrind
'
,
binary
,
'
--tool=%s
'
%
self
.
tool
]
return
[
'
valgrind
'
,
binary
,
'
--tool=%s
'
%
self
.
tool
]
class
CLanguage
(
object
):
def
__init__
(
self
,
make_target
):
self
.
allow_hashing
=
True
self
.
make_target
=
make_target
def
test_binaries
(
self
,
config
):
return
glob
.
glob
(
'
bins/%s/*_test
'
%
config
)
def
make_targets
(
self
):
return
[
'
buildtests_%s
'
%
self
.
make_target
]
def
build_steps
(
self
):
return
[]
class
PhpLanguage
(
object
):
def
__init__
(
self
):
self
.
allow_hashing
=
False
def
test_binaries
(
self
,
config
):
return
[
'
src/php/bin/run_tests.sh
'
]
def
make_targets
(
self
):
return
[]
def
build_steps
(
self
):
return
[[
'
tools/run_tests/build_php.sh
'
]]
# different configurations we can run under
# different configurations we can run under
_CONFIGS
=
{
_CONFIGS
=
{
'
dbg
'
:
SimpleConfig
(
'
dbg
'
),
'
dbg
'
:
SimpleConfig
(
'
dbg
'
),
...
@@ -51,10 +84,10 @@ _CONFIGS = {
...
@@ -51,10 +84,10 @@ _CONFIGS = {
_DEFAULT
=
[
'
dbg
'
,
'
opt
'
]
_DEFAULT
=
[
'
dbg
'
,
'
opt
'
]
_LANGUAGE
_BUILD_RULE
=
{
_LANGUAGE
S
=
{
'
c++
'
:
[
'
make
'
,
'
buildtests_
cxx
'
]
,
'
c++
'
:
CLanguage
(
'
cxx
'
)
,
'
c
'
:
[
'
make
'
,
'
buildtests_
c
'
]
,
'
c
'
:
CLanguage
(
'
c
'
)
,
'
php
'
:
[
'
tools/run_tests/build_php.sh
'
]
'
php
'
:
PhpLanguage
()
}
}
# parse command line
# parse command line
...
@@ -63,7 +96,6 @@ argp.add_argument('-c', '--config',
...
@@ -63,7 +96,6 @@ argp.add_argument('-c', '--config',
choices
=
[
'
all
'
]
+
sorted
(
_CONFIGS
.
keys
()),
choices
=
[
'
all
'
]
+
sorted
(
_CONFIGS
.
keys
()),
nargs
=
'
+
'
,
nargs
=
'
+
'
,
default
=
_DEFAULT
)
default
=
_DEFAULT
)
argp
.
add_argument
(
'
-t
'
,
'
--test-filter
'
,
nargs
=
'
*
'
,
default
=
[
'
*
'
])
argp
.
add_argument
(
'
-n
'
,
'
--runs_per_test
'
,
default
=
1
,
type
=
int
)
argp
.
add_argument
(
'
-n
'
,
'
--runs_per_test
'
,
default
=
1
,
type
=
int
)
argp
.
add_argument
(
'
-f
'
,
'
--forever
'
,
argp
.
add_argument
(
'
-f
'
,
'
--forever
'
,
default
=
False
,
default
=
False
,
...
@@ -74,9 +106,9 @@ argp.add_argument('--newline_on_success',
...
@@ -74,9 +106,9 @@ argp.add_argument('--newline_on_success',
action
=
'
store_const
'
,
action
=
'
store_const
'
,
const
=
True
)
const
=
True
)
argp
.
add_argument
(
'
-l
'
,
'
--language
'
,
argp
.
add_argument
(
'
-l
'
,
'
--language
'
,
choices
=
sorted
(
_LANGUAGE
_BUILD_RULE
.
keys
()),
choices
=
sorted
(
_LANGUAGE
S
.
keys
()),
nargs
=
'
+
'
,
nargs
=
'
+
'
,
default
=
sorted
(
_LANGUAGE
_BUILD_RULE
.
keys
()))
default
=
sorted
(
_LANGUAGE
S
.
keys
()))
args
=
argp
.
parse_args
()
args
=
argp
.
parse_args
()
# grab config
# grab config
...
@@ -86,21 +118,17 @@ run_configs = set(_CONFIGS[cfg]
...
@@ -86,21 +118,17 @@ run_configs = set(_CONFIGS[cfg]
for
x
in
args
.
config
))
for
x
in
args
.
config
))
build_configs
=
set
(
cfg
.
build_config
for
cfg
in
run_configs
)
build_configs
=
set
(
cfg
.
build_config
for
cfg
in
run_configs
)
make_targets
=
set
()
make_targets
=
[]
build_steps
=
[]
languages
=
set
(
_LANGUAGES
[
l
]
for
l
in
args
.
language
)
for
language
in
args
.
language
:
build_steps
=
[[
'
make
'
,
cmd
=
_LANGUAGE_BUILD_RULE
[
language
]
'
-j
'
,
'
%d
'
%
(
multiprocessing
.
cpu_count
()
+
1
),
if
cmd
[
0
]
==
'
make
'
:
'
CONFIG=%s
'
%
cfg
]
+
list
(
set
(
make_targets
.
update
(
cmd
[
1
:])
itertools
.
chain
.
from_iterable
(
l
.
make_targets
()
else
:
for
l
in
languages
)))
build_steps
.
append
(
cmd
)
for
cfg
in
build_configs
]
+
list
(
if
make_targets
:
itertools
.
chain
.
from_iterable
(
l
.
build_steps
()
build_steps
=
[[
'
make
'
,
for
l
in
languages
))
'
-j
'
,
'
%d
'
%
(
multiprocessing
.
cpu_count
()
+
1
),
'
CONFIG=%s
'
%
cfg
]
+
list
(
make_targets
)
for
cfg
in
build_configs
]
+
build_steps
filters
=
args
.
test_filter
runs_per_test
=
args
.
runs_per_test
runs_per_test
=
args
.
runs_per_test
forever
=
args
.
forever
forever
=
args
.
forever
...
@@ -146,28 +174,26 @@ def _build_and_run(check_cancelled, newline_on_success, cache):
...
@@ -146,28 +174,26 @@ def _build_and_run(check_cancelled, newline_on_success, cache):
return
1
return
1
# run all the tests
# run all the tests
if
not
jobset
.
run
(
one_run
=
dict
(
itertools
.
ifilter
(
(
'
'
.
join
(
config
.
run_command
(
x
)),
config
.
run_command
(
x
))
lambda
x
:
x
is
not
None
,
(
for
config
in
run_configs
config
.
run_command
(
x
)
for
language
in
args
.
language
for
config
in
run_configs
for
x
in
_LANGUAGES
[
language
].
test_binaries
(
config
.
build_config
)
for
filt
in
filters
).
values
()
for
x
in
itertools
.
chain
.
from_iterable
(
itertools
.
repeat
(
all_runs
=
itertools
.
chain
.
from_iterable
(
glob
.
glob
(
'
bins/%s/%s_test
'
%
(
itertools
.
repeat
(
one_run
,
runs_per_test
))
config
.
build_config
,
filt
)),
if
not
jobset
.
run
(
all_runs
,
check_cancelled
,
runs_per_test
)))),
newline_on_success
=
newline_on_success
,
check_cancelled
,
maxjobs
=
min
(
c
.
maxjobs
for
c
in
run_configs
),
newline_on_success
=
newline_on_success
,
cache
=
cache
):
maxjobs
=
min
(
c
.
maxjobs
for
c
in
run_configs
),
cache
=
cache
):
return
2
return
2
return
0
return
0
test_cache
=
(
None
if
runs_per_test
!=
1
test_cache
=
(
None
or
'
gcov
'
in
build_configs
if
not
all
(
x
.
allow_hashing
or
'
valgrind
'
in
build
_configs
for
x
in
itertools
.
chain
(
languages
,
run
_configs
))
else
TestCache
())
else
TestCache
())
if
test_cache
:
if
test_cache
:
test_cache
.
maybe_load
()
test_cache
.
maybe_load
()
...
@@ -187,6 +213,7 @@ if forever:
...
@@ -187,6 +213,7 @@ if forever:
'
All tests are now passing properly
'
,
'
All tests are now passing properly
'
,
do_newline
=
True
)
do_newline
=
True
)
jobset
.
message
(
'
IDLE
'
,
'
No change detected
'
)
jobset
.
message
(
'
IDLE
'
,
'
No change detected
'
)
if
test_cache
:
test_cache
.
save
()
while
not
have_files_changed
():
while
not
have_files_changed
():
time
.
sleep
(
1
)
time
.
sleep
(
1
)
else
:
else
:
...
@@ -197,5 +224,5 @@ else:
...
@@ -197,5 +224,5 @@ else:
jobset
.
message
(
'
SUCCESS
'
,
'
All tests passed
'
,
do_newline
=
True
)
jobset
.
message
(
'
SUCCESS
'
,
'
All tests passed
'
,
do_newline
=
True
)
else
:
else
:
jobset
.
message
(
'
FAILED
'
,
'
Some tests failed
'
,
do_newline
=
True
)
jobset
.
message
(
'
FAILED
'
,
'
Some tests failed
'
,
do_newline
=
True
)
test_cache
.
save
()
if
test_cache
:
test_cache
.
save
()
sys
.
exit
(
result
)
sys
.
exit
(
result
)
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