Skip to content

refactor: improve test isolation using TempDir utility#1578

Merged
dengbo11 merged 1 commit into
OpenAtom-Linyaps:masterfrom
myml:fix-test-tmpdir
Feb 3, 2026
Merged

refactor: improve test isolation using TempDir utility#1578
dengbo11 merged 1 commit into
OpenAtom-Linyaps:masterfrom
myml:fix-test-tmpdir

Conversation

@myml

@myml myml commented Feb 2, 2026

Copy link
Copy Markdown
Collaborator
  1. Replaced manual file cleanup in test setup/teardown with TempDir utility
  2. Removed global helper functions for temporary file paths
  3. Moved lock file and version file creation to individual test cases
  4. Added proper TempDir header inclusion
  5. Each test now creates its own isolated temporary directory

This change improves test isolation by ensuring each test case has its own
clean temporary environment, eliminating potential interference between tests.
The TempDir utility automatically handles directory creation and cleanup,
making the tests more robust and maintainable.

Influence:

  1. Verify all test cases still pass individually and collectively
  2. Confirm no file conflicts occur when running tests in parallel
  3. Check that temporary files are properly cleaned up after test execution
  4. Ensure test isolation prevents cross-test contamination

refactor: 使用 TempDir 工具改进测试隔离性

  1. 使用 TempDir 工具替代测试设置/清理中的手动文件清理
  2. 移除了用于临时文件路径的全局辅助函数
  3. 将锁文件和版本文件创建移至各个测试用例中
  4. 添加了正确的 TempDir 头文件包含
  5. 每个测试现在创建自己独立的临时目录

此更改通过确保每个测试用例都有自己干净的临时环境来提高测试隔离性,
消除了测试之间潜在的干扰。TempDir 工具自动处理目录创建和清理,
使测试更加健壮和可维护。

Influence:

  1. 验证所有测试用例单独和集体运行时仍然通过
  2. 确认并行运行测试时不会发生文件冲突
  3. 检查测试执行后临时文件是否正确清理
  4. 确保测试隔离性防止跨测试污染

1. Replaced manual file cleanup in test setup/teardown with TempDir
utility
2. Removed global helper functions for temporary file paths
3. Moved lock file and version file creation to individual test cases
4. Added proper TempDir header inclusion
5. Each test now creates its own isolated temporary directory

This change improves test isolation by ensuring each test case has its
own
clean temporary environment, eliminating potential interference between
tests.
The TempDir utility automatically handles directory creation and
cleanup,
making the tests more robust and maintainable.

Influence:
1. Verify all test cases still pass individually and collectively
2. Confirm no file conflicts occur when running tests in parallel
3. Check that temporary files are properly cleaned up after test
execution
4. Ensure test isolation prevents cross-test contamination

refactor: 使用 TempDir 工具改进测试隔离性

1. 使用 TempDir 工具替代测试设置/清理中的手动文件清理
2. 移除了用于临时文件路径的全局辅助函数
3. 将锁文件和版本文件创建移至各个测试用例中
4. 添加了正确的 TempDir 头文件包含
5. 每个测试现在创建自己独立的临时目录

此更改通过确保每个测试用例都有自己干净的临时环境来提高测试隔离性,
消除了测试之间潜在的干扰。TempDir 工具自动处理目录创建和清理,
使测试更加健壮和可维护。

Influence:
1. 验证所有测试用例单独和集体运行时仍然通过
2. 确认并行运行测试时不会发生文件冲突
3. 检查测试执行后临时文件是否正确清理
4. 确保测试隔离性防止跨测试污染
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @myml, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the isolation and maintainability of the test suite by integrating the TempDir utility. This change automates the creation and cleanup of temporary directories for each test, thereby preventing potential interference between tests and ensuring a clean, independent environment for every execution. The refactoring also streamlines test code by removing manual file management and global helper functions.

Highlights

  • Test Setup Refactoring: Refactored test setup and teardown procedures to leverage the TempDir utility, automating temporary file and directory management.
  • Removal of Global Helpers: Eliminated global helper functions previously responsible for generating temporary file paths, simplifying the test codebase.
  • Decentralized File Creation: Moved the creation of lock files and version files into individual test cases, ensuring each test manages its own temporary resources.
  • Header Inclusion: Ensured proper inclusion of the TempDir header in relevant test files.
  • Enhanced Test Isolation: Each test now operates within its own isolated temporary directory, preventing potential interference and improving test reliability.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request is a great step towards improving test isolation by using the TempDir utility. The changes correctly refactor most of the tests to create their own temporary environments, which is a significant improvement for test robustness and maintainability. However, I've found one test case, CreatesDirectoryForLockFile in application_singleton_test.cpp, where the refactoring is incomplete. It introduces a TempDir instance but doesn't use it, continuing to rely on the system's shared temporary directory and manual file cleanup. This oversight undermines the goal of complete test isolation. My review comment provides details on this issue. Once this is addressed, the PR will be in excellent shape.

Comment on lines +101 to +102
TempDir temp_dir;
auto lockFilePath = temp_dir.path() / "ll_driver_detect_singleton_test.lock";

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.

high

The temp_dir and lockFilePath variables are unused in this test. The test logic continues to use std::filesystem::temp_directory_path() directly and performs manual cleanup, which goes against the goal of this refactoring for better test isolation. This test should be updated to use the temp_dir to construct its paths and rely on RAII for cleanup, making it consistent with other tests in this file.

@codecov

codecov Bot commented Feb 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

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

@deepin-ci-robot

Copy link
Copy Markdown
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: dengbo11, myml

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@dengbo11 dengbo11 merged commit 2677d19 into OpenAtom-Linyaps:master Feb 3, 2026
15 checks passed
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.

3 participants