Skip to content

Commit d4704d2

Browse files
committed
Optionally keep temporary files from integration tests.
Set environment variable `METAFIX_KEEP_TEMP=true`.
1 parent be32875 commit d4704d2

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

metafix/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ task integrationTest(type: Exec, group: 'Verification') {
8585
}
8686

8787
environment.METAFIX_DISABLE_TO_DO = System.getProperty('org.metafacture.metafix.disableToDo')
88+
environment.METAFIX_KEEP_TEMP = System.getProperty('org.metafacture.metafix.keepTemp')
8889
}
8990

9091
task install(dependsOn: publishToMavenLocal, group: 'Publishing',

metafix/integrationTest.sh

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ function parse_boolean() {
2727

2828
parse_boolean "$METAFIX_DISABLE_TO_DO" && disable_todo=1 || disable_todo=
2929
parse_boolean "$METAFIX_INTEGRATION_TEST_PROFILE" && noprofile= || noprofile=no
30+
parse_boolean "$METAFIX_KEEP_TEMP" && keep_temp=1 || keep_temp=
3031

3132
[ -t 1 -a -x /usr/bin/colordiff ] && colordiff=colordiff || colordiff=cat
3233

@@ -67,6 +68,10 @@ function die() {
6768
exit 2
6869
}
6970

71+
function rm_temp() {
72+
[ -n "$keep_temp" ] || rm -f "$@"
73+
}
74+
7075
function run_metafix() {
7176
$gradle_command --console=plain -p "$root_directory" :metafix-runner:run --args="$1" -P${noprofile}profile="${1%.*}"
7277
}
@@ -120,8 +125,8 @@ function get_file() {
120125
function command_info() {
121126
log " ${color_info}${1^} command exit status$color_reset: $2"
122127

123-
[ -s "$3" ] && log " ${color_info}${1^} command output$color_reset: $3" || rm -f "$3"
124-
[ -s "$4" ] && log " ${color_info}${1^} command error$color_reset: $4" || rm -f "$4"
128+
[ -s "$3" ] && log " ${color_info}${1^} command output$color_reset: $3" || rm_temp "$3"
129+
[ -s "$4" ] && log " ${color_info}${1^} command error$color_reset: $4" || rm_temp "$4"
125130

126131
log
127132
}
@@ -166,7 +171,7 @@ function test_failed() {
166171
log " Output: ${12}"
167172
log " Diff: ${13}"
168173

169-
[ -s "${13}" ] && $colordiff <"${13}" || rm -f "${13}"
174+
[ -s "${13}" ] && $colordiff <"${13}" || rm_temp "${13}"
170175
fi
171176

172177
command_info "$5" "$6" "$7" "$8"
@@ -222,7 +227,7 @@ function run_tests() {
222227
if diff -u "$test_expected" "$metafix_output" >"$metafix_diff"; then
223228
test_passed "$test" "$test_todo" "$metafix_elapsed_time"
224229

225-
rm -f "$metafix_diff" "$metafix_command_output" "$metafix_command_error"
230+
rm_temp "$metafix_diff" "$metafix_command_output" "$metafix_command_error"
226231
else
227232
test_failed "$test" "$test_todo" "$metafix_elapsed_time" FAILED\
228233
metafix "$metafix_exit_status" "$metafix_command_output" "$metafix_command_error"\

0 commit comments

Comments
 (0)