-
Notifications
You must be signed in to change notification settings - Fork 64
Fix Windows tests failing in CI #225
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
base: main
Are you sure you want to change the base?
Fix Windows tests failing in CI #225
Conversation
On Windows, recipe paths passed with forward slashes (e.g., "Breakfast/pancakes.cook") need to be converted to backslashes before passing to cooklang-find library. This fixes tests that use forward slashes in path arguments, which work on Unix but fail on Windows where the native path separator is backslash. Changes: - src/util/mod.rs: get_recipe() normalizes path separators - src/recipe/read.rs: normalize CLI recipe path argument - src/server/handlers/recipes.rs: normalize URL path to filesystem path - src/server/ui.rs: normalize URL path to filesystem path
Code Review: Fix Windows tests failing in CIThank you for addressing the Windows path separator issue! This is an important cross-platform fix. Strengths
Code Quality Concerns1. Code Duplication (Medium Priority) The same normalization logic is duplicated in 4 different files. Recommend creating a helper function in src/util/mod.rs to reduce duplication and make the logic easier to test. 2. Variable Shadowing In src/util/mod.rs, the code shadows clean_name which could be confusing. A helper function would avoid this pattern. 3. Missing Test Coverage Good news: The test at tests/cli_integration_test.rs:246 already tests forward slashes in paths. Verify it now passes on Windows. Potential Bugs1. Incomplete Solution for Mixed Separators If a user on Windows types native backslashes, the URL might not work correctly through the web server routing. Does the web server need reverse conversion? 2. Consider Using std::path::MAIN_SEPARATOR_STR The codebase already uses MAIN_SEPARATOR elsewhere (e.g., src/util/cooklang_to_human.rs:283). Using it here would be more idiomatic and consistent. Summary
Recommended Actions
Overall, this is a solid fix for an important issue. The main improvement would be reducing code duplication. Nice work! |
- shopping_list.rs: normalize path separators before processing - shopping_list.rs: use MAIN_SEPARATOR instead of hardcoded '/' for path detection - shopping_list.rs: handle both ./ and .\ prefixes - util/mod.rs: handle both ./ and .\ prefixes in get_recipe
Code Review: Fix Windows tests failing in CIThank you for tackling the Windows path separator issue! This is an important cross-platform compatibility fix. I've reviewed the changes and have several observations and suggestions. ✅ Strengths
|
On Windows, recipe paths passed with forward slashes (e.g., "Breakfast/pancakes.cook") need to be converted to backslashes before passing to cooklang-find library.
This fixes tests that use forward slashes in path arguments, which work on Unix but fail on Windows where the native path separator is backslash.
Changes: