Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
dumux-repositories
dumux
Commits
ae76d3d3
Commit
ae76d3d3
authored
May 21, 2021
by
Dennis Gläser
Browse files
[bin][findtests] make functions accept build-dir
parent
9ecda465
Changes
1
Hide whitespace changes
Inline
Side-by-side
bin/testing/findtests.py
View file @
ae76d3d3
...
...
@@ -25,10 +25,10 @@ def hasCommonMember(myset, mylist):
# make dry run and return the compilation command
def
getCompileCommand
(
testConfig
):
lines
=
subprocess
.
check_output
([
"make"
,
"--dry-run"
,
testConfig
[
"target"
]]
,
encoding
=
'ascii'
).
splitlines
()
def
getCompileCommand
(
testConfig
,
buildTreeRoot
=
'.'
):
lines
=
subprocess
.
check_output
([
"make"
,
"--dry-run"
,
testConfig
[
"target"
]],
encoding
=
'ascii'
,
cwd
=
buildTreeRoot
).
splitlines
()
def
hasCppCommand
(
line
):
return
any
(
cpp
in
line
for
cpp
in
[
'g++'
,
'clang++'
])
...
...
@@ -39,8 +39,8 @@ def getCompileCommand(testConfig):
# get the command and folder to compile the given test
def
buildCommandAndDir
(
testConfig
,
cache
):
compCommand
=
getCompileCommand
(
testConfig
)
def
buildCommandAndDir
(
testConfig
,
cache
,
buildTreeRoot
=
'.'
):
compCommand
=
getCompileCommand
(
testConfig
,
buildTreeRoot
)
if
compCommand
is
None
:
with
open
(
cache
)
as
c
:
data
=
json
.
load
(
c
)
...
...
@@ -53,12 +53,13 @@ def buildCommandAndDir(testConfig, cache):
# check if a test is affected by changes in the given files
def
isAffectedTest
(
testConfigFile
,
changedFiles
):
def
isAffectedTest
(
testConfigFile
,
changedFiles
,
buildTreeRoot
=
'.'
):
with
open
(
testConfigFile
)
as
configFile
:
testConfig
=
json
.
load
(
configFile
)
cacheFile
=
"TestTargets/"
+
testConfig
[
"target"
]
+
".json"
command
,
dir
=
buildCommandAndDir
(
testConfig
,
cacheFile
)
cacheFile
=
os
.
path
.
join
(
buildTreeRoot
,
cacheFile
)
command
,
dir
=
buildCommandAndDir
(
testConfig
,
cacheFile
,
buildTreeRoot
)
mainFile
=
command
[
-
1
]
# detect headers included in this test
...
...
@@ -94,27 +95,27 @@ if __name__ == '__main__':
help
=
'The path to the top-level build directory of the project to be checked'
)
args
=
vars
(
parser
.
parse_args
())
buildDir
=
os
.
path
.
abspath
(
args
[
'build_dir'
])
targetFile
=
os
.
path
.
abspath
(
args
[
'outfile'
])
with
open
(
args
[
'file_list'
])
as
files
:
changedFiles
=
set
([
line
.
strip
(
'
\n
'
)
for
line
in
files
.
readlines
()])
owd
=
os
.
getcwd
()
os
.
chdir
(
args
[
'build_dir'
])
# clean build directory
subprocess
.
run
([
"make"
,
"clean"
])
subprocess
.
run
([
"make"
]
)
subprocess
.
run
([
"make"
,
"clean"
]
,
cwd
=
buildDir
)
subprocess
.
run
([
"make"
,
"all"
],
cwd
=
buildDir
)
# create cache folder
os
.
makedirs
(
"TestTargets"
,
exist_ok
=
True
)
os
.
makedirs
(
os
.
path
.
join
(
buildDir
,
"TestTargets"
)
,
exist_ok
=
True
)
# detect affected tests
print
(
"Detecting affected tests:"
)
affectedTests
=
{}
tests
=
glob
(
"TestMetaData/*json"
)
tests
=
glob
(
os
.
path
.
join
(
buildDir
,
"TestMetaData
"
)
+
"
/*json"
)
numProcesses
=
max
(
1
,
args
[
'num_processes'
])
findAffectedTest
=
partial
(
isAffectedTest
,
changedFiles
=
changedFiles
)
findAffectedTest
=
partial
(
isAffectedTest
,
changedFiles
=
changedFiles
,
buildTreeRoot
=
buildDir
)
with
Pool
(
processes
=
numProcesses
)
as
p
:
for
affected
,
name
,
target
in
p
.
imap_unordered
(
findAffectedTest
,
tests
,
chunksize
=
4
):
if
affected
:
...
...
@@ -125,5 +126,3 @@ if __name__ == '__main__':
with
open
(
targetFile
,
'w'
)
as
jsonFile
:
json
.
dump
(
affectedTests
,
jsonFile
)
os
.
chdir
(
owd
)
Dennis Gläser
@DennisGlaeser
mentioned in commit
bffd84f3
·
Jun 02, 2021
mentioned in commit
bffd84f3
mentioned in commit bffd84f3e6ec5ada85159c7e22c9ac6906e7c60b
Toggle commit list
Write
Preview
Supports
Markdown
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