-
Notifications
You must be signed in to change notification settings - Fork 118
Fixed Trailing Slashes in cp command + added unit tests #3921
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
Fixed Trailing Slashes in cp command + added unit tests #3921
Conversation
|
Hey @shreyas-goenka Can you review this pr |
|
Hi @varundeepsaini ! Thanks for the PR! Contributing to CLI requires a signed CLA If that's something you're willing to do, please reach out with a request to sign the CLA to dabs-feedback@databricks.com, and we will take it from there. Thank you! |
|
Hey @andrewnester Have sent the email |
|
@andrewnester |
|
@andrewnester any idea why the integration tests havent run yet ? |
|
@varundeepsaini I manually triggered integration tests, they should run now |
|
Commit: b25ff1c
27 failing tests:
Top 50 slowest tests (at least 2 minutes):
|
Head branch was pushed to by a user without write access
|
@andrewnester |
|
An authorized user can trigger integration tests manually by following the instructions below: Trigger: Inputs:
Checks will be approved automatically on success. |
|
@andrewnester could you queue the integration tests |
|
Commit: 134c1a8
15 failing tests:
Top 50 slowest tests (at least 2 minutes):
|
Fixes: #2835 ## Changes Fixed handling of trailing directory separators in the `cp` command. When a target path ends with `/` or `\`, the command now validates that the directory exists before copying. If the directory doesn't exist, it returns a clear error message instead of failing later. Added a helper function `hasTrailingDirSeparator` to detect trailing directory separators for both Unix-style (`/`) and Windows-style (`\`) paths. ## Why Previously, the `cp` command didn't properly handle trailing directory separators. When users specified a target path like `target/dir/` (expecting it to be treated as a directory), the command would not validate that the directory exists first, leading to confusing error messages later in the copy process. This change ensures that trailing directory separators are explicitly treated as indicating a directory target, and validates that the directory exists upfront. ## Tests Added unit tests in `integration/cmd/fs/cp_test.go`: - `TestFsCpFileToNonExistentDir`: Tests copying files to both existing and non-existent directories with trailing slashes - `TestFsCpFileToNonExistentDirWindowsPaths`: Windows-specific tests for trailing backslashes (`\`) and forward slashes (`/`) on Windows The tests verify that: - Copying to an existing directory with a trailing separator succeeds - Copying to a non-existent directory with a trailing separator returns an appropriate error message - Both Unix-style (`/`) and Windows-style (`\`) separators are handled correctly --------- Co-authored-by: Andrew Nester <andrew.nester.dev@gmail.com>
Fixes: #2835
Changes
Fixed handling of trailing directory separators in the
cpcommand. When a target path ends with/or\, the command now validates that the directory exists before copying. If the directory doesn't exist, it returns a clear error message instead of failing later.Added a helper function
hasTrailingDirSeparatorto detect trailing directory separators for both Unix-style (/) and Windows-style (\) paths.Why
Previously, the
cpcommand didn't properly handle trailing directory separators. When users specified a target path liketarget/dir/(expecting it to be treated as a directory), the command would not validate that the directory exists first, leading to confusing error messages later in the copy process. This change ensures that trailing directory separators are explicitly treated as indicating a directory target, and validates that the directory exists upfront.Tests
Added unit tests in
integration/cmd/fs/cp_test.go:TestFsCpFileToNonExistentDir: Tests copying files to both existing and non-existent directories with trailing slashesTestFsCpFileToNonExistentDirWindowsPaths: Windows-specific tests for trailing backslashes (\) and forward slashes (/) on WindowsThe tests verify that:
/) and Windows-style (\) separators are handled correctly