Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
IPDSnelting
mjtest
Commits
c04aa203
Commit
c04aa203
authored
Oct 30, 2016
by
Johannes Bechberger
Browse files
Fix installation and Windows issues
parent
9a87aac9
Changes
6
Hide whitespace changes
Inline
Side-by-side
mjtest/__init__.py
View file @
c04aa203
VERSION
=
"0.42"
\ No newline at end of file
mjtest/cli.py
View file @
c04aa203
...
...
@@ -2,9 +2,11 @@ import logging
import
os
from
pprint
import
pprint
import
sys
import
mjtest.util.utils
from
os.path
import
dirname
sys
.
path
.
append
(
dirname
(
__file__
))
import
util.utils
import
argparse
from
mjtest.
environment
import
TestMode
,
Environment
,
TEST_MODES
from
environment
import
TestMode
,
Environment
,
TEST_MODES
from
mjtest.test.tests
import
TestSuite
# adapted from http://stackoverflow.com/a/8527629
...
...
mjtest/environment.py
View file @
c04aa203
...
...
@@ -55,16 +55,15 @@ class Environment:
self
.
parallel
=
parallel
self
.
timeout
=
timeout
if
tmp
_dir
:
if
report
_dir
:
self
.
report_dir
=
os
.
path
.
abspath
(
os
.
path
.
expandvars
(
report_dir
))
if
not
os
.
path
.
exists
(
report_dir
):
os
.
mkdir
(
self
.
report_dir
)
else
:
self
.
report_dir
=
os
.
path
.
join
(
get_mjtest_basedir
(),
"reports"
)
if
not
os
.
path
.
exists
(
self
.
report_dir
):
os
.
mkdir
(
self
.
report_dir
)
self
.
report_dir
=
os
.
path
.
join
(
self
.
report_dir
,
datetime
.
now
().
strftime
(
"%d
.
%m
.
%y
:%X
"
))
self
.
report_dir
=
os
.
path
.
join
(
self
.
report_dir
,
datetime
.
now
().
strftime
(
"%d
-
%m
-
%y
_%H-%M-%S
"
))
os
.
mkdir
(
self
.
report_dir
)
logging
.
basicConfig
(
level
=
self
.
LOG_LEVELS
[
log_level
])
...
...
mjtest/test/__init__.py
View file @
c04aa203
__author__
=
'parttimenerd'
mjtest/util/shell.py
View file @
c04aa203
...
...
@@ -5,7 +5,13 @@ Convenience function
Alternative to subprocess and os.system
"""
import
subprocess
import
resource
has_resource_module
=
True
try
:
import
resource
except
ImportError
:
has_resource_module
=
False
pass
import
sys
import
signal
import
threading
...
...
@@ -24,6 +30,8 @@ class SigKill(Exception):
def
_lower_rlimit
(
res
,
limit
):
if
not
has_resource_module
:
return
(
soft
,
hard
)
=
resource
.
getrlimit
(
res
)
if
soft
>
limit
or
soft
==
resource
.
RLIM_INFINITY
:
soft
=
limit
...
...
@@ -51,6 +59,8 @@ class _Execute(object):
rlimit
[
'RLIMIT_FSIZE'
]
=
512
*
MB
def
_set_rlimit
(
self
):
if
not
has_resource_module
:
return
if
self
.
timeout
>
0.0
:
_lower_rlimit
(
resource
.
RLIMIT_CPU
,
self
.
timeout
)
for
k
,
v
in
self
.
rlimit
.
items
():
...
...
@@ -58,11 +68,14 @@ class _Execute(object):
def
_run_process
(
self
):
try
:
prexec_args
=
{}
if
has_resource_module
:
prexec_args
[
"preexec_fn"
]
=
self
.
_set_rlimit
self
.
proc
=
subprocess
.
Popen
(
self
.
cmd
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
,
preexec_fn
=
self
.
_set_rlimit
,
env
=
self
.
env
)
env
=
self
.
env
,
**
prexec_args
)
x
=
self
.
proc
.
communicate
()
self
.
out
,
self
.
err
=
x
self
.
returncode
=
self
.
proc
.
returncode
...
...
@@ -107,6 +120,8 @@ def execute(cmd, env=None, timeout=0, rlimit=None, propagate_sigint=True):
rlimit
=
dict
()
if
cmd
is
str
:
cmd
=
filter
(
lambda
x
:
x
,
cmd
.
split
(
' '
))
else
:
cmd
=
list
(
filter
(
lambda
x
:
x
,
cmd
[
0
].
split
(
' '
)))
+
cmd
[
1
:]
exc
=
_Execute
(
cmd
,
timeout
,
env
,
rlimit
)
(
out
,
err
,
returncode
)
=
exc
.
run
()
if
returncode
==
-
signal
.
SIGINT
:
...
...
mjtest/util/utils.py
View file @
c04aa203
...
...
@@ -5,7 +5,7 @@ import sys
def
get_mjtest_basedir
()
->
str
:
return
path
.
dirname
(
path
.
dirname
(
path
.
dirname
(
path
.
abs
path
(
__file__
))))
return
path
.
dirname
(
path
.
dirname
(
path
.
dirname
(
path
.
real
path
(
__file__
))))
""" Colored logging handler that is used for the root logger """
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment