diff --git a/vars/helper.groovy b/vars/helper.groovy
index a028bbcece6cec12d52942f1cc9326147034aec7..3ba8f64d6564c264ce90795dc31303c03291ba21 100644
--- a/vars/helper.groovy
+++ b/vars/helper.groovy
@@ -238,10 +238,8 @@ def doValgrind(String label, String buildType) {
         # It might be either relative to the directory the CTestTestfile.cmake is in, or absolute. Check for both.
         if [ -f "\${test}" ]; then
           EXECLIST="\${EXECLIST} `realpath \${test}`"
-          TESTDIR="\${dir}"
-        elif [ -f "\${dir}\${test}" ]; then
-          EXECLIST="\${EXECLIST} `realpath \${dir}\${test}`"
-          TESTDIR="\${dir}"
+        elif [ -f "\${dir}/\${test}" ]; then
+          EXECLIST="\${EXECLIST} `realpath \${dir}/\${test}`"
         fi
       done