From dc28d106a9a80fd1a9c5a6423c1d1e1493c787bf Mon Sep 17 00:00:00 2001 From: Iveta Wiedermann Date: Fri, 10 Mar 2023 15:17:20 +0100 Subject: [PATCH] Delete installed files irrespective of rubygems version Lower version of rubygems doesn't have 'user_gemhome' env variable therefore there's a condition using different approach. --- .../test.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Sanity/native-extension-gem-is-installed-without-error/test.sh b/Sanity/native-extension-gem-is-installed-without-error/test.sh index 24574c9..56f84f3 100755 --- a/Sanity/native-extension-gem-is-installed-without-error/test.sh +++ b/Sanity/native-extension-gem-is-installed-without-error/test.sh @@ -19,7 +19,15 @@ rlJournalStart rlPhaseEnd rlPhaseStartCleanup - rlRun "su -c 'gem env user_gemhome | xargs rm -rf' $TEST_USER" 0 "Delete installed files" + + rlLogInfo "Deleting installed files" + su -c 'set -o pipefail; gem env user_gemhome | xargs rm -rf' $TEST_USER || \ + su -c 'set -o pipefail; gem env | grep "USER INSTALLATION DIRECTORY:" | awk '"'"'{print $5}'"'"' | xargs rm -rf' $TEST_USER + [ $? != 0 ] && rlFail "Deleting installed files wasn't successful" + + # on RHEL temporary file cleanup unit tends to be started for $TEST_USER session and with that + # userdel fails because user process is running, so this is to workaround the problem + command -v loginctl >/dev/null && rlRun "loginctl terminate-user $TEST_USER" 0,1 rlRun "userdel -r $TEST_USER" rlRun "popd" rlRun "rm -r $tmp" 0 "Remove tmp directory"