Skip to content

[CI][C++] Remove useless test-file-cleanup step #51096

Closed

Description

@pitrou

Describe the enhancement requested

We have a test file cleanup in run-test.sh that calls find twice with the same parameters, computes the difference and tries to delete files only in the second result. But nothing happens between the two find calls: the results should always be the same (except if there's a race condition).

Since this code isn't doing anything useful, and it doesn't seem to cause any problem, we should just remove it.

if [ "$ATTEMPT_NUMBER" -lt "$TEST_EXECUTION_ATTEMPTS" ]; then
# If the test fails, the test output may or may not be left behind,
# depending on whether the test cleaned up or exited immediately. Either
# way we need to clean it up. We do this by comparing the data directory
# contents before and after the test runs, and deleting anything new.
#
# The comm program requires that its two inputs be sorted.
TEST_TMPDIR_BEFORE=$(find "$TEST_TMPDIR" -maxdepth 1 -type d | sort)
fi
if [ "$ATTEMPT_NUMBER" -lt "$TEST_EXECUTION_ATTEMPTS" ]; then
# Now delete any new test output.
TEST_TMPDIR_AFTER=$(find "$TEST_TMPDIR" -maxdepth 1 -type d | sort)
DIFF=$(comm -13 <(echo "$TEST_TMPDIR_BEFORE") \
<(echo "$TEST_TMPDIR_AFTER"))
for DIR in $DIFF; do
# Multiple tests may be running concurrently. To avoid deleting the
# wrong directories, constrain to only directories beginning with the
# test name.
#
# This may delete old test directories belonging to this test, but
# that's not typically a concern when rerunning flaky tests.
if [[ $DIR =~ ^$TEST_TMPDIR/$TEST_NAME ]]; then
echo Deleting leftover flaky test directory "$DIR"
rm -Rf "$DIR"
fi
done
fi

Component(s)

C++, Continuous Integration

Activity

  1. pitrou commented on Aug 31, 2026

    @pitrou
    MemberAuthor
  2. pitrou commented on Aug 31, 2026

    @pitrou
    MemberAuthor

    Also, $TEST_TMPDIR doesn't seem to be defined...

  3. Diveyam-Mishra commented on Aug 31, 2026

    @Diveyam-Mishra
    Contributor

    Seems like a very straight up solution Would like to take this up as my first issue in this repo ?

  4. pitrou commented on Aug 31, 2026

    @pitrou
    MemberAuthor

    @Diveyam-Mishra Definitely, but I would like to wait for @kou 's opinion before we do this.

  5. kou commented on Aug 31, 2026

    @kou
    Member

    Good catch. It seems that this was introduced by GH-29.

    We can remove the retry feature entirely from this script because we can use the CTest's retry feature.

    @Diveyam-Mishra Could you add "take" only comment here to assign this issue to you?

  6. Diveyam-Mishra commented on Aug 31, 2026

    @Diveyam-Mishra
    Contributor

    take

  7. added a commit that references this issue on Sep 1, 2026
  8. added this to the 26.0.0 milestone on Sep 1, 2026
  9. kou commented on Sep 1, 2026

    @kou
    Member

    Issue resolved by pull request 51110
    #51110

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions