Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
dumux
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
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
dumux-repositories
dumux
Commits
ae76d3d3
Commit
ae76d3d3
authored
3 years ago
by
Dennis Gläser
Browse files
Options
Downloads
Patches
Plain Diff
[bin][findtests] make functions accept build-dir
parent
9ecda465
No related branches found
No related tags found
1 merge request
!2626
feature/refactor-test-selection
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bin/testing/findtests.py
+17
-18
17 additions, 18 deletions
bin/testing/findtests.py
with
17 additions
and
18 deletions
bin/testing/findtests.py
+
17
−
18
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
)
This diff is collapsed.
Click to expand it.
Dennis Gläser
@DennisGlaeser
mentioned in commit
bffd84f3
·
3 years ago
mentioned in commit
bffd84f3
mentioned in commit bffd84f3e6ec5ada85159c7e22c9ac6906e7c60b
Toggle commit list
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