Skip to content

Commit 2661ab8

Browse files
committed
Run integration tests directly from the distribution. (#577)
Instead of via Gradle; reduces the total runtime by about 50 %.
1 parent dc7e5e6 commit 2661ab8

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed

metafix/build.gradle

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ test {
8888
}
8989

9090
task integrationTest(type: Exec, group: 'Verification') {
91+
def installDist = ':metafacture-runner:installDist'
92+
dependsOn installDist
93+
9194
executable './integrationTest.sh'
9295

9396
if (project.hasProperty('args')) {
@@ -96,10 +99,15 @@ task integrationTest(type: Exec, group: 'Verification') {
9699

97100
if (project.hasProperty('profile')) {
98101
environment.METAFACTURE_INTEGRATION_TEST_PROFILE = project.getProperty('profile')
102+
environment.METAFACTURE_INTEGRATION_TEST_PROFILE_DEPTH = project.hasProperty('profile.depth') ? project.getProperty('profile.depth') : 8
99103
}
100104

101105
environment.METAFACTURE_INTEGRATION_TEST_DISABLE_TO_DO = System.getProperty('org.metafacture.metafix.disableToDo')
102106
environment.METAFACTURE_INTEGRATION_TEST_KEEP_TEMP = System.getProperty('org.metafacture.metafix.keepTemp')
107+
108+
doFirst {
109+
environment.METAFACTURE_HOME = tasks.getByPath(installDist).destinationDir
110+
}
103111
}
104112

105113
task validateFixFile(type: JavaExec, group: 'Verification') {

metafix/integrationTest.sh

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,15 @@ root_directory="$PWD"
2121
data_directory="$root_directory/src/test/resources/org/metafacture/metafix/integration"
2222
gradle_command="$root_directory/../gradlew"
2323

24+
flux_command="$METAFACTURE_HOME/flux.sh"
25+
2426
function parse_boolean() {
2527
[ "${1,,}" == true ]
2628
}
2729

2830
parse_boolean "$METAFACTURE_INTEGRATION_TEST_DISABLE_TO_DO" && disable_todo=1 || disable_todo=
2931
parse_boolean "$METAFACTURE_INTEGRATION_TEST_KEEP_TEMP" && keep_temp=1 || keep_temp=
30-
parse_boolean "$METAFACTURE_INTEGRATION_TEST_PROFILE" && noprofile= || noprofile=no
32+
parse_boolean "$METAFACTURE_INTEGRATION_TEST_PROFILE" && profile=1 || profile=
3133
parse_boolean "$CI" && ci=1 || ci=
3234

3335
[ -t 1 -a -x /usr/bin/colordiff ] && colordiff=colordiff || colordiff=cat
@@ -74,8 +76,19 @@ function rm_temp() {
7476
}
7577

7678
function run_metafix() {
77-
local file=$1; shift
78-
$gradle_command --console=plain -p "$root_directory" :metafacture-runner:run --args="$file" -P${noprofile}profile="${file%.*}" $@
79+
local file=$1 args=$2 opts=(); shift 2
80+
81+
if [ -r "$args" ]; then
82+
opts+=($(<"$args"))
83+
fi
84+
85+
if [ -n "$profile" ]; then
86+
# See metafacture-runner/build.gradle (application)
87+
opts+=("-XX:FlightRecorderOptions=stackdepth=${METAFACTURE_INTEGRATION_TEST_PROFILE_DEPTH:-8}")
88+
opts+=("-XX:StartFlightRecording=dumponexit=true,filename=${file%.*}.jfr,settings=profile")
89+
fi
90+
91+
FLUX_JAVA_OPTIONS="${opts[@]}" $flux_command "$file" "$@"
7992
}
8093

8194
function run_catmandu() {
@@ -229,7 +242,7 @@ function run_tests() {
229242

230243
metafix_start_time=$(current_time)
231244

232-
run_metafix "$test_directory/$metafix_file" $(cat "$metafix_command_args" 2>/dev/null || true) >"$metafix_command_output" 2>"$metafix_command_error"
245+
run_metafix "$test_directory/$metafix_file" "$metafix_command_args" >"$metafix_command_output" 2>"$metafix_command_error"
233246
metafix_exit_status=$?
234247

235248
metafix_elapsed_time=$(elapsed_time "$metafix_start_time")
@@ -276,6 +289,8 @@ function run_tests() {
276289
return $matched
277290
}
278291

292+
[ -n "$METAFACTURE_HOME" -a -x "$flux_command" ] || die "Please install the metafacture-core distribution first and set the METAFACTURE_HOME environment variable to its path."
293+
279294
start_time=$(current_time)
280295

281296
if [ $# -eq 0 ]; then

0 commit comments

Comments
 (0)