Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mjtest
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
IPDSnelting
mjtest
Commits
a546fdae
Commit
a546fdae
authored
Nov 28, 2016
by
Johannes Bechberger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use process local tmp directories
parent
8fc40c3f
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
5 deletions
+11
-5
mjtest/environment.py
mjtest/environment.py
+9
-0
mjtest/test/exec_tests.py
mjtest/test/exec_tests.py
+1
-3
mjtest/test/syntax_tests.py
mjtest/test/syntax_tests.py
+1
-2
No files found.
mjtest/environment.py
View file @
a546fdae
...
...
@@ -5,6 +5,8 @@ import shutil
import
tempfile
from
datetime
import
datetime
import
time
from
typing
import
Dict
from
mjtest.util.shell
import
execute
from
mjtest.util.utils
import
get_mjtest_basedir
,
force_colored_output
import
mjtest.util.utils
...
...
@@ -94,6 +96,7 @@ class Environment:
self
.
ci_testing
=
ci_testing
self
.
_tmp_file_ctr
=
0
self
.
_already_preprocessed_files
=
set
()
self
.
_pid_tmpdirs
=
{}
# type: Dict[int, str]
def
create_tmpfile
(
self
)
->
str
:
self
.
_tmp_file_ctr
+=
1
...
...
@@ -105,6 +108,12 @@ class Environment:
os
.
mkdir
(
dir
)
return
dir
def
create_pid_local_tmpdir
(
self
)
->
str
:
pid
=
os
.
getpid
()
if
pid
not
in
self
.
_pid_tmpdirs
:
self
.
_pid_tmpdirs
[
pid
]
=
self
.
create_tmpdir
()
return
self
.
_pid_tmpdirs
[
pid
]
def
clean_up
(
self
):
if
not
self
.
own_tmp_dir
:
shutil
.
rmtree
(
self
.
tmp_dir
)
...
...
mjtest/test/exec_tests.py
View file @
a546fdae
...
...
@@ -35,7 +35,7 @@ class JavaExecTest(BasicSyntaxTest):
def
run
(
self
)
->
BasicDiffTestResult
:
base_filename
=
path
.
basename
(
self
.
file
).
split
(
"."
)[
0
]
tmp_dir
=
self
.
env
.
create_tmpdir
()
tmp_dir
=
self
.
env
.
create_
pid_local_
tmpdir
()
shutil
.
copy
(
self
.
preprocessed_file
,
path
.
join
(
tmp_dir
,
base_filename
+
".java"
))
cwd
=
os
.
getcwd
()
os
.
chdir
(
tmp_dir
)
...
...
@@ -46,7 +46,6 @@ class JavaExecTest(BasicSyntaxTest):
if
javac_rtcode
!=
0
:
_LOG
.
error
(
"File
\"
{}
\"
isn't valid Java"
.
format
(
self
.
preprocessed_file
))
os
.
chdir
(
cwd
)
shutil
.
rmtree
(
tmp_dir
)
raise
InterruptedError
()
exp_out
,
_
,
_
=
\
self
.
env
.
run_command
(
"java"
,
base_filename
)
...
...
@@ -62,7 +61,6 @@ class JavaExecTest(BasicSyntaxTest):
out
,
_
,
_
=
self
.
env
.
run_command
(
"./"
+
base_filename
)
out
=
out
.
decode
().
strip
()
os
.
chdir
(
cwd
)
shutil
.
rmtree
(
tmp_dir
)
if
self
.
type
==
self
.
MODE
and
self
.
env
.
mode
==
self
.
MODE
:
return
BasicDiffTestResult
(
self
,
rtcode
,
out
,
err
.
decode
(),
exp_out
)
return
BasicTestResult
(
self
,
rtcode
,
out
.
decode
(),
err
.
decode
())
...
...
mjtest/test/syntax_tests.py
View file @
a546fdae
...
...
@@ -39,11 +39,10 @@ class JavaCompileTest(BasicSyntaxTest):
def
__init__
(
self
,
env
:
Environment
,
type
:
str
,
file
:
str
,
preprocessed_file
:
str
):
super
().
__init__
(
env
,
type
,
file
,
preprocessed_file
)
tmp_dir
=
self
.
env
.
create_tmpdir
()
tmp_dir
=
self
.
env
.
create_
pid_local_
tmpdir
()
_
,
self
.
javac_err
,
self
.
javac_rtcode
=
\
self
.
env
.
run_command
(
"javac"
,
path
.
relpath
(
preprocessed_file
),
"-d"
,
tmp_dir
,
"-verbose"
)
self
.
javac_err
=
self
.
javac_err
.
decode
()
# type: str
shutil
.
rmtree
(
tmp_dir
,
ignore_errors
=
True
)
self
.
_should_succeed
=
self
.
_is_file_syntactically_correct
()
if
self
.
SYNTAX_TEST
else
self
.
javac_rtcode
==
0
def
_is_file_syntactically_correct
(
self
):
...
...
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