-
Notifications
You must be signed in to change notification settings - Fork 0
Make tests cross-platform #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @ackkerman, 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 test suite's cross-platform compatibility, primarily by addressing how git shims and environment variables (specifically PATH) are handled. The changes enable the tests to run reliably on Windows by providing appropriate shim scripts and a robust mechanism for PATH manipulation, ensuring that the test environment correctly interacts with git.
Highlights
- Cross-Platform Test Compatibility: Introduced platform-specific
gitshim scripts (.cmdfor Windows, shell scripts for Unix-like systems) to ensure tests behave correctly across different operating systems. - Environment Variable Handling: Implemented a new helper function
path_varsto manage thePATHenvironment variable in a cross-platform compatible way, correctly prepending the shim directory and preserving the originalPATH. - Shim Script Refinement: Modified
gitshim scripts to utilize anORIG_PATHenvironment variable. This allows the shims to temporarily restore the original systemPATHwhen needing to call the realgitexecutable (e.g., forgit configcommands), preventing recursion or incorrect behavior. - Test Code Simplification: Refactored test functions (
connect_and_list_roundtrip,pull_falls_back_to_add,pull_with_custom_message,remove_mapping) to use the newpath_varshelper, reducing duplication and improving clarity in howPATHis set for test commands.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| 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 issue 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 or fill out our survey to provide feedback.
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
-
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. ↩
There was a problem hiding this comment.
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 successfully makes the test suite cross-platform by introducing platform-specific git shims and correctly handling the PATH environment variable. The use of std::env::join_paths and std::env::split_paths is a great improvement for portability.
My review focuses on improving the maintainability of the newly added test helpers. I've suggested refactoring to reduce code duplication between the shim-creation functions and improving the readability of the embedded shell scripts.
tests/cli.rs
Outdated
| .unwrap(); | ||
|
|
||
| let script = if cfg!(windows) { | ||
| "@echo off\r\nif \"%1\"==\"config\" (\r\n set \"PATH=%ORIG_PATH%\"\r\n git %*\r\n) else (\r\n echo git %*\r\n exit /b 0\r\n)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This single-line batch script is a bit hard to read. For better readability and maintainability, you could format it as a multi-line string using the concat! macro. This combines string literals at compile time with no performance cost.
| "@echo off\r\nif \"%1\"==\"config\" (\r\n set \"PATH=%ORIG_PATH%\"\r\n git %*\r\n) else (\r\n echo git %*\r\n exit /b 0\r\n)" | |
| concat!( | |
| "@echo off\r\n", | |
| "if \"%1\"==\"config\" (\r\n", | |
| " set \"PATH=%ORIG_PATH%\"\r\n", | |
| " git %*\r\n", | |
| ") else (\r\n", | |
| " echo git %*\r\n", | |
| " exit /b 0\r\n", | |
| ")" | |
| ) |
tests/cli.rs
Outdated
| &shim, | ||
|
|
||
| let script = if cfg!(windows) { | ||
| "@echo off\r\nif \"%1\"==\"config\" (\r\n set \"PATH=%ORIG_PATH%\"\r\n git %*\r\n) else if \"%1\"==\"remote\" if \"%2\"==\"get-url\" (\r\n exit /b 1\r\n) else if \"%1\"==\"subtree\" if \"%2\"==\"pull\" (\r\n echo hint: use 'git subtree add' 1>&2\r\n exit /b 1\r\n) else (\r\n echo git %*\r\n exit /b 0\r\n)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This long, single-line batch script is difficult to read and maintain. To improve readability, you can format it as a multi-line string using the concat! macro. This will make the script's logic much clearer without any runtime overhead.
| "@echo off\r\nif \"%1\"==\"config\" (\r\n set \"PATH=%ORIG_PATH%\"\r\n git %*\r\n) else if \"%1\"==\"remote\" if \"%2\"==\"get-url\" (\r\n exit /b 1\r\n) else if \"%1\"==\"subtree\" if \"%2\"==\"pull\" (\r\n echo hint: use 'git subtree add' 1>&2\r\n exit /b 1\r\n) else (\r\n echo git %*\r\n exit /b 0\r\n)" | |
| concat!( | |
| "@echo off\r\n", | |
| "if \"%1\"==\"config\" (\r\n", | |
| " set \"PATH=%ORIG_PATH%\"\r\n", | |
| " git %*\r\n", | |
| ") else if \"%1\"==\"remote\" if \"%2\"==\"get-url\" (\r\n", | |
| " exit /b 1\r\n", | |
| ") else if \"%1\"==\"subtree\" if \"%2\"==\"pull\" (\r\n", | |
| " echo hint: use 'git subtree add' 1>&2\r\n", | |
| " exit /b 1\r\n", | |
| ") else (\r\n", | |
| " echo git %*\r\n", | |
| " exit /b 0\r\n", | |
| ")" | |
| ) |
|
test(windows): forward
|
Summary
join_pathsso tests work cross‑platformORIG_PATHinside shims to call the real gitTesting
cargo testhttps://chatgpt.com/codex/tasks/task_e_6880bd6cd2b08330b23ef46b770a6e3e