cvp2004 opened a new issue, #27812:
URL: https://github.com/apache/datafusion/issues/27812

   ### Describe the bug
   
   There are two Windows-only problems in `xtask`. CI runs clippy and the xtask 
tests only on Linux, so neither shows up there.
   
   1. **Clippy fails on Windows.**
   
      In `executable_in` (`xtask/src/command.rs`), the `#[cfg(windows)]` block 
ends with a `return ...;` statement, which triggers 
[`clippy::needless_return`](https://rust-lang.github.io/rust-clippy/master/index.html#needless_return).
 Because `ci/scripts/rust_clippy.sh` runs clippy with `-D warnings`, 
`./dev/rust_lint.sh` fails on Windows:
   
      ```text
      error: unneeded `return` statement
         --> xtask\src\command.rs:516:9
          |
      516 | /         return 
extensions.to_string_lossy().split(';').any(|extension| {
      517 | |             is_executable_file(
      518 | |                 
&candidate.with_extension(extension.trim_start_matches('.')),
      519 | |             )
      520 | |         });
          | |__________^
          |
          = note: `-D clippy::needless-return` implied by `-D warnings`
      ```
   
   2. **The `ci_steps::tests::explain_all_available_ci_commands` snapshot test 
fails on Windows.**
   
      The `microbenchmarks` step in `xtask/src/ci_steps.rs` builds 
`CLICKBENCH_DATA_PATH` with:
   
      ```rust
      self.root.join("datafusion/core/tests/data/clickbench_hits_10.parquet")
      ```
   
      On Windows, `Path::join` inserts a `\` separator, so the rendered command 
doesn't match the snapshot:
   
      ```diff
      
-CLICKBENCH_DATA_PATH=/workspace/datafusion/core/tests/data/clickbench_hits_10.parquet
 \
      
+CLICKBENCH_DATA_PATH='/workspace\datafusion/core/tests/data/clickbench_hits_10.parquet'
 \
      ```
   
      This only affects the test output. The path itself still works on Windows.
   
   Both were introduced in #26765.
   
   ### To Reproduce
   
   On Windows (`x86_64-pc-windows-msvc`, toolchain `1.99.1` from 
`rust-toolchain.toml`), from the repository root:
   
   ```shell
   # 1. Clippy error
   cargo clippy --all-targets -p datafusion-xtask -- -D warnings
   
   # 2. Snapshot test failure
   cargo test -p datafusion-xtask
   ```
   
   Running the full lint suite also hits (1), because it stops at the clippy 
step:
   
   ```shell
   ./dev/rust_lint.sh
   ```
   
   ### Expected behavior
   
   Both commands pass on Windows, as they do on Linux:
   
   - `cargo clippy --all-targets -p datafusion-xtask -- -D warnings` reports no 
warnings.
   - `cargo test -p datafusion-xtask` passes, including 
`ci_steps::tests::explain_all_available_ci_commands`.
   
   ### Additional context
   
   **Proposed fix for (1)**
   
   Drop the `return` and the trailing `;` so the expression becomes the value 
of the `#[cfg(windows)]` block, as clippy suggests:
   
   ```diff
   -        return extensions.to_string_lossy().split(';').any(|extension| {
   +        extensions.to_string_lossy().split(';').any(|extension| {
                is_executable_file(
                    
&candidate.with_extension(extension.trim_start_matches('.')),
                )
   -        });
   +        })
   ```
   
   I've checked locally that clippy and `cargo fmt --all -- --check` pass on 
Windows with this change.
   
   **Possible fixes for (2)**
   
   This one needs a decision on approach, and I'm happy to follow whichever 
maintainers prefer:
   
   - Normalize path separators to `/` when the step commands are rendered for 
the snapshot.
   - Build the path from components so the rendered output doesn't depend on 
the platform.
   
   **CI coverage**
   
   There's no Windows job in `.github/workflows/rust.yml`, so regressions like 
these can't be caught in CI today. I'm not proposing to add one as part of this 
issue.
   
   ### Willingness to contribute
   
   I plan to contribute a fix for this bug independently


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to