Skip to content

Clean up temp recordings left in OS temp dir by rec-play tests - #15162

Merged
Nir-Az merged 1 commit into
realsenseai:developmentfrom
Nir-Az:cleanup-temp-recordings
Jun 4, 2026
Merged

Nir-Az merged 1 commit into
realsenseai:developmentfrom
Nir-Az:cleanup-temp-recordings

Conversation

@Nir-Az

@Nir-Az Nir-Az commented Jun 4, 2026 •

Copy link
Copy Markdown
Collaborator

Overview: Two rec-play unit tests created a recording under a tempfile.mkdtemp() directory in the OS temp dir and never deleted it, so the folders accumulated in %TEMP% on Windows across runs. This switches them to auto-cleaned temp handling and documents the rule.

Tracked on [RSDSO-21593]

Summary

  • unit-tests/live/rec-play/pytest-record-and-stream.py — use pytest's tmp_path fixture (auto-cleaned, self-pruning) instead of tempfile.mkdtemp(); drop now-unused os/tempfile imports.
  • unit-tests/live/rec-play/test-record-software-device.py — legacy flat script (no pytest fixtures): wrap record/play in try/finally with shutil.rmtree(temp_dir, ignore_errors=True) so the temp dir is removed even when the test fails.
  • .github/skills/pytest-infra.md — add migration-checklist item 15 + a "Writing a New Pytest Test" callout teaching the tmp_path rule (and the legacy-script fallback) so new/migrated tests don't reintroduce the leak.

Why

tempfile.mkdtemp() without cleanup leaks its directory into the OS temp dir permanently; Windows never auto-prunes %TEMP%, so these recording folders piled up on CI/dev machines.

Test plan

  • python -m py_compile on both edited test files.
  • pytest-record-and-stream.py — PASSED [D455-114222251272]; recording lands under pytest's auto-pruned temp base.
  • test-record-software-device.py — passes; with %TEMP% redirected to an empty sandbox, 0 leftover entries after the run.

@Nir-Az
Nir-Az requested a review from AviaAv June 4, 2026 12:24

@Nir-Az Nir-Az left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rs-agentic bot — automated code review

This review was auto-generated by the rs-agentic bot.

The PR is clean and well-motivated. Found a couple of points worth addressing (details in the inline comments).

Summary

File Change Assessment
replaces bare ✅ Correct pattern per guideline item 15
✅ Correct pattern for legacy scripts — one minor concern (see inline)
Documents new rule ✅ Clear and follows existing doc style

@AviaAv AviaAv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Nir-Az
Nir-Az merged commit 2bacff5 into realsenseai:development Jun 4, 2026
29 of 30 checks passed
@Nir-Az
Nir-Az deleted the cleanup-temp-recordings branch June 4, 2026 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants