Skip to content

Unify temporary directory allocation strategy in tests#160

Merged
cottsay merged 1 commit into
colcon:masterfrom
KmoM88:KmoM88/tmp-path
Jun 15, 2026
Merged

Unify temporary directory allocation strategy in tests#160
cottsay merged 1 commit into
colcon:masterfrom
KmoM88:KmoM88/tmp-path

Conversation

@KmoM88

@KmoM88 KmoM88 commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Following the upstream unification in colcon/colcon-core#729, this PR refactors the test suite to use the modern tmp_path fixture (which provides a pathlib.Path object) instead of mixing multiple temporary directory strategies.

Specifically, this package previously mixed:

  • Manual TemporaryDirectory management (in test/test_package_identification_cmake.py, test/test_environment_cmake_prefix_path.py, and test/test_environment_cmake_module_path.py)
  • Pytest tmpdir fixture (in test/test_task_cmake_build.py)

This refactor:

  1. Adds a test/conftest.py compatibility fixture for tmp_path (supporting older pytest versions, such as those on Enterprise Linux 8).
  2. Updates all four identified test files to accept and utilize the tmp_path fixture, removing the need for manual context managers or castings.
  3. Updates test/spell_check.words to account for new spelling words introduced by the compatibility fixture (isdigit, itertools, linux, takewhile, tmpdir) and removes the now-unused tempfile.
  4. Makes minor style/formatting adjustments to test/test_flake8.py to prevent line-length limits (E501) when adding common ignore lists.

Reference

Specifics

Unlike some packages in the ecosystem which solely used TemporaryDirectory or tmpdir, colcon-cmake had a mix of both.

🤖 Assisted by Gemini

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 54.74%. Comparing base (ce2b56c) to head (6ae832c).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #160   +/-   ##
=======================================
  Coverage   54.74%   54.74%           
=======================================
  Files          10       10           
  Lines         780      780           
  Branches      163      163           
=======================================
  Hits          427      427           
  Misses        307      307           
  Partials       46       46           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@cottsay
cottsay merged commit fa3f2a0 into colcon:master Jun 15, 2026
22 checks passed
@cottsay cottsay added the enhancement New feature or request label Jun 16, 2026
@cottsay cottsay added this to the 0.2.30 milestone Jun 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants