-
Notifications
You must be signed in to change notification settings - Fork 286
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
feat: add tests for local wsh file copy cmd #1911
Conversation
This adds tests for the corner cases of the `wsh file copy` command. At the moment, these focus on local copies since they are more easily replicated.
Warning Rate limit exceeded@oneirocosm has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 12 minutes and 9 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (2)
WalkthroughThe changes add a comprehensive suite of new shell script test cases under the testing directory. These tests verify the behavior of a file copy command across various scenarios. They cover operations such as copying files with different path formats (including relative paths, multiple slashes, tilde and environment variable expansion), handling errors when copying a file to itself, and addressing both successful and failed copy attempts. The tests also evaluate directory copy operations, including recursive copying of empty directories, copying nested directories, and the handling of non-existing target directories. In addition, a runner script is introduced to iterate through all test cases, while utility functions are added for setting up and cleaning up the testing environment. Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 11
🧹 Nitpick comments (71)
tests/copytests/cases/test030.sh (2)
1-3
: Missing Shebang Line
The file currently lacks a shebang, which is useful for explicitly specifying the shell interpreter (e.g., bash). Adding a shebang (e.g., "#!/bin/bash") improves portability and helps tools like Shellcheck identify the correct shell environment.🧰 Tools
🪛 Shellcheck (0.10.0)
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
4-7
: Directory Setup and Robustness
The commands to change directory, create the directory "baz", and create an empty file "baz/foo.txt" are correct. However, consider using "mkdir -p baz" to prevent potential errors if the "baz" directory already exists.Suggested diff:
-mkdir baz +mkdir -p baztests/copytests/cases/test026.sh (1)
1-4
: Add a shebang directive for clarity.
It is recommended to include a shebang (e.g., "#!/usr/bin/env bash") at the very top of the file. This helps tools like ShellCheck determine the correct shell syntax and can prevent potential issues in environments where the default shell may differ.Consider applying the following diff:
+#!/usr/bin/env bash
🧰 Tools
🪛 Shellcheck (0.10.0)
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test016.sh (2)
1-3
: Add a Shebang for Clarity
Static analysis (SC2148) suggests adding a shebang to clearly specify the intended shell environment. Consider inserting a line like:+#!/bin/bash
at the very top of the file to ensure consistent behavior across environments.
🧰 Tools
🪛 Shellcheck (0.10.0)
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
5-5
: Changing to Test Directory
Switching to "$HOME/testcp" assumes that the directory exists and is properly set up by your test runner. If the test environment does not guarantee this, you might want to add directory creation or error handling.tests/copytests/cases/test027.sh (2)
1-3
: Add a Shebang for Shell SpecificationWhile the file starts with comments, it currently lacks a shebang line, which is recommended for shell scripts (per Shellcheck SC2148). Adding a shebang (e.g., "#!/bin/bash") at the top ensures that the script executes with the intended shell interpreter.
Suggested diff:
+#!/bin/bash
🧰 Tools
🪛 Shellcheck (0.10.0)
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
10-13
: Verification Block Works as ExpectedThe subsequent if-statement correctly checks for the existence of the copied file "baz". Consider enhancing this in the future by also verifying that the content of "baz" matches that of "foo.txt" (if applicable). For now, checking the file’s existence is sufficient.
tests/copytests/cases/test047.sh (2)
1-1
: Add a Shebang DirectiveIt’s recommended to include a shebang (for example, #!/bin/bash) at the very beginning of the script. This not only resolves the shellcheck warning (SC2148) but also explicitly defines the shell interpreter for consistency.
Suggested diff:
+#!/bin/bash +# copy a file with /// to a file with //🧰 Tools
🪛 Shellcheck (0.10.0)
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
4-9
: Ensure Test Directory ExistsThe script uses “cd "$HOME/testcp"” without verifying if the test directory exists. To avoid potential failures (especially in environments where $HOME/testcp might not be pre-created), consider checking for or creating this directory (e.g., via “mkdir -p $HOME/testcp”).
tests/copytests/cases/test015.sh (2)
1-3
: Add a Shebang for Better Shell Compatibility.
The script currently lacks a shebang line. Adding one (e.g., "#!/bin/bash" at the top) will help static analysis tools and users correctly identify and execute the script.🧰 Tools
🪛 Shellcheck (0.10.0)
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
10-13
: Enhance Post-Copy Verification.
The test currently checks for the existence of "foo.txt"—the source file—which is expected to remain after a copy operation. However, to fully validate the copy functionality, consider also verifying that the destination file ("bar.txt") exists. For example:-if [ ! -f foo.txt ]; then - echo "foo.txt does not exist" - exit 1 -fi +if [ ! -f bar.txt ]; then + echo "bar.txt does not exist" + exit 1 +fiThis adjustment ensures that the file copy is successful and the destination file is created as expected.
tests/copytests/cases/test045.sh (3)
1-3
: Add a Shebang for Interpreter SpecificationIt's recommended to add a shebang (e.g. #!/bin/bash) at the very top of the file. This helps static analysis tools (like ShellCheck, which raised an SC2148 error) and ensures that the script runs with the intended shell interpreter.
+#!/bin/bash
🧰 Tools
🪛 Shellcheck (0.10.0)
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
4-5
: Ensure Test Environment Directory ExistsThe script changes the directory with "cd "$HOME/testcp"", which assumes that this directory already exists. To increase robustness, consider creating the directory if it does not exist.
- cd "$HOME/testcp" + mkdir -p "$HOME/testcp" + cd "$HOME/testcp"
6-9
: Simplify Nested Directory CreationInstead of separately creating the parent directory and its subdirectory, you can simplify the code by using "mkdir -p" to create nested directories in one command. This reduces the risk of errors if the parent directory already exists.
- mkdir foo - mkdir foo/bar + mkdir -p foo/bartests/copytests/cases/test005.sh (3)
4-7
: Environment Setup Consideration
The setup commands (using "set -e", changing to "$HOME/testcp", and creating "foo.txt") are clear. However, to make the test more robust, consider ensuring that the directory "$HOME/testcp" exists before attempting to change into it (e.g. using "mkdir -p $HOME/testcp").
8-8
: Validate File Copy Operation
The command "wsh file copy foo.txt ./bar.txt" is the key operation being tested. While "set -e" will stop the script on failure, it might be beneficial to capture the outcome of the copy operation by verifying that the destination file ("./bar.txt") exists after execution.
10-13
: Ensure Comprehensive Validation of Copy Process
This block verifies the existence of the source file ("foo.txt") after the copy operation. Since the primary purpose of the test is to validate the file copy behavior (especially with destination paths starting with "./"), consider also adding an assertion to check that the destination file ("./bar.txt") was created successfully and its content (if applicable) matches the source.tests/copytests/cases/test019.sh (2)
1-3
: Add Shebang Directive
It’s best practice to add a shebang (e.g., #!/bin/bash) at the top of shell scripts to clearly specify the intended shell and avoid warnings from tools like ShellCheck.Suggested diff:
+#!/bin/bash
🧰 Tools
🪛 Shellcheck (0.10.0)
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
4-7
: Ensure Test Directory Exists
The use of “set -e” and navigating to the test directory with “cd” is appropriate. However, to make the test more robust in environments where the directory might not exist, consider creating the directory before changing into it.Suggested diff (to be added before the cd command):
+mkdir -p "$HOME/testcp"
tests/copytests/cases/test052.sh (3)
1-1
: Add a shebang for shell clarityStatic analysis pointed out the lack of a shebang. Adding a line like "#!/usr/bin/env bash" at the top ensures the script is interpreted by the intended shell and resolves the SC2148 warning.
Proposed diff:
+#!/usr/bin/env bash
🧰 Tools
🪛 Shellcheck (0.10.0)
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
27-27
: Quote variables in the conditional checkQuoting the variables in the
if
statement helps prevent potential word-splitting issues if either checksum variable is empty.Proposed diff:
-if [ $FOO_MD5 != $CORGE_MD5 ]; then +if [ "$FOO_MD5" != "$CORGE_MD5" ]; then
20-21
: Ensure deterministic zip archive creationWhen using
zip -r
, extra file attributes (like timestamps) might lead to nondeterministic archives and differing MD5 checksums even if the file contents are identical. Consider adding the-X
flag to exclude such metadata, ensuring that the checksum comparison reliably reflects the file content integrity.Proposed diff for both zip commands:
-zip -r foo.zip foo >/dev/null 2>&1 +zip -r -X foo.zip foo >/dev/null 2>&1Also applies to: 24-25
tests/copytests/cases/test035.sh (1)
4-7
: Setup Commands Review
The commands on lines 4–7 (using set -e, changing to "$HOME/testcp", and creating the 'bar' directory) are straightforward. One suggestion is to verify that "$HOME/testcp" exists or create it if missing, to ensure robust test setup in varied environments.tests/copytests/cases/test044.sh (2)
4-9
: Improve Test Setup Robustness
The setup commands clearly prepare the test environment. To make the test more robust against pre-existing directories, consider using "mkdir -p" instead of separate "mkdir" calls. This change avoids potential errors if the directories already exist.Suggested diff:
-mkdir foo -mkdir foo/bar +mkdir -p foo/bar
12-15
: Verification of Copy Outcome is Appropriate
The conditional check effectively verifies that "qux/bar/baz.txt" exists after the copy operation. For improved output clarity, you might add a success message when the file is found.Optional diff suggestion:
+echo "Test passed: qux/bar/baz.txt exists."
tests/copytests/cases/test049.sh (4)
1-2
: Missing Shebang Directive
It is recommended to add a shebang (e.g., "#!/usr/bin/env bash") at the very top of the script so that the appropriate shell is explicitly defined and static analysis tools like Shellcheck (SC2148) are properly satisfied.🧰 Tools
🪛 Shellcheck (0.10.0)
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
4-5
: Ensure Test Directory Exists
The script assumes that "$HOME/testcp" already exists. If this directory might not be present in some environments, consider creating it (or checking its existence) before running subsequent commands.
6-8
: Robust Directory Creation
Using plain "mkdir" may cause the script to fail if the directories already exist. Consider using "mkdir -p" to make the test more robust and idempotent for repeated runs, unless failing on pre-existing directories is desired.
18-18
: Optional Cleanup Consideration
Although not critical for the test’s purpose, you might consider adding cleanup steps to remove or reset the test directories after execution. This helps avoid potential interference with subsequent tests.tests/copytests/cases/test007.sh (3)
1-1
: Add a shebang for consistent shell behavior
It's recommended to add a shebang (for example, #!/bin/bash) at the very top of the script. This ensures that the script is executed using the expected shell and resolves the static analysis warning (SC2148).🧰 Tools
🪛 Shellcheck (0.10.0)
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
4-6
: Verify the test environment directory
Before changing the directory to "$HOME/testcp", consider adding a check to ensure that the directory exists. This will help avoid unexpected failures if the test directory isn’t already created.
8-8
: Enhance post-copy validation
The script executes the copy command using "wsh file copy ./foo.txt ./bar.txt". While it later confirms that "foo.txt" still exists, it would also be beneficial to verify that the destination file "bar.txt" was created as expected. Adding a check for "bar.txt" would provide a more robust test of the file copy functionality.tests/copytests/cases/test039.sh (2)
1-1
: Add a Shebang DirectiveIt’s a good practice to start shell scripts with an explicit shebang (e.g. "#!/bin/bash") to declare the intended interpreter. This also clears the Shellcheck warning regarding an unknown target shell.
Consider applying the following diff:
+#!/bin/bash
🧰 Tools
🪛 Shellcheck (0.10.0)
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
11-14
: Check for Unwanted File CreationThe if-condition testing for the existence of "baz/foo.txt" correctly validates that no files have been erroneously copied. As an additional improvement, you might consider also verifying that the target directory "baz" was not created if that is within the scope of the test.
tests/copytests/testutil.sh (2)
1-8
: Consistent Directory Path Usage
In the setup_testcp function, the directory is checked using "$HOME/testcp" but then created with ~/testcp. For consistency and clarity (especially in quoted contexts), change:- mkdir ~/testcp + mkdir "$HOME/testcp"🧰 Tools
🪛 Shellcheck (0.10.0)
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
1-1
: Optional: Add Shebang
If this file may be executed directly (instead of only being sourced), consider adding a shebang (e.g., #!/bin/bash) at the top.🧰 Tools
🪛 Shellcheck (0.10.0)
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test006.sh (1)
1-3
: Recommendation: Add a ShebangIt’s recommended to add a shebang (e.g., "#!/bin/bash") at the top of this file. This explicitly specifies the shell interpreter and helps address Shellcheck warnings (SC2148).
🧰 Tools
🪛 Shellcheck (0.10.0)
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test012.sh (1)
1-3
: Recommendation: Add a ShebangPlease add a shebang (e.g., "#!/bin/bash") at the top of the file to explicitly set the shell environment and avoid shell interpretation issues.
🧰 Tools
🪛 Shellcheck (0.10.0)
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test013.sh (2)
1-3
: Recommendation: Add a ShebangConsider adding a shebang (e.g., "#!/bin/bash") at the beginning of the script to ensure it’s executed in the intended shell and to address Shellcheck's suggestions.
🧰 Tools
🪛 Shellcheck (0.10.0)
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
4-13
: Test Logic: Validating Source File PersistenceThis test invokes the copy command with the destination path using tilde expansion and then confirms that the source file "foo.txt" still exists. While this correctly ensures that the copy operation doesn’t remove the original, you might also consider verifying that the destination ("bar.txt") was created to confirm a successful copy.
tests/copytests/cases/test011.sh (1)
1-3
: Recommendation: Add a ShebangPlease add a shebang (e.g., "#!/bin/bash") at the top of the file to specify the shell interpreter, which will help prevent shell-specific issues and satisfy Shellcheck’s guidance.
🧰 Tools
🪛 Shellcheck (0.10.0)
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test014.sh (1)
1-3
: Recommendation: Add a ShebangIt is advisable to add a shebang (e.g., "#!/bin/bash") at the beginning of the script. This clarifies the intended shell interpreter and rectifies the Shellcheck warning (SC2148).
🧰 Tools
🪛 Shellcheck (0.10.0)
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test008.sh (1)
1-1
: Add a Shebang Directive.
To satisfy Shellcheck (SC2148) and to ensure consistent execution across environments, add a shebang (e.g. "#!/bin/bash") at the top of the script.🧰 Tools
🪛 Shellcheck (0.10.0)
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test021.sh (1)
1-1
: Add a Shebang Directive.
Include a shebang (e.g. "#!/bin/bash") at the start to clearly specify the shell for this script.🧰 Tools
🪛 Shellcheck (0.10.0)
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test023.sh (1)
1-1
: Add a Shebang Directive.
Please add a shebang such as "#!/bin/bash" at the top to resolve the Shellcheck warning and ensure the script uses the intended shell.🧰 Tools
🪛 Shellcheck (0.10.0)
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test032.sh (1)
1-1
: Add a Shebang Directive.
Adding a shebang (e.g. "#!/bin/bash") at the top of the file is recommended to handle the Shellcheck hint.🧰 Tools
🪛 Shellcheck (0.10.0)
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test024.sh (1)
1-1
: Add a Shebang Directive.
To address Shellcheck warnings and improve portability, add a shebang (e.g. "#!/bin/bash") at the beginning of the script.🧰 Tools
🪛 Shellcheck (0.10.0)
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test034.sh (1)
1-3
: Add a shebang for clarity.
It is recommended to add a shebang (e.g. #!/bin/bash) at the top of the script to resolve shellcheck warnings (SC2148) and ensure the intended shell is used.Suggested diff:
+#!/bin/bash
🧰 Tools
🪛 Shellcheck (0.10.0)
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test046.sh (1)
1-3
: Add a shebang for consistency.
Including a shebang (e.g. #!/bin/bash) at the top will improve portability and suppress shellcheck warnings regarding an unspecified target shell.Suggested diff:
+#!/bin/bash
🧰 Tools
🪛 Shellcheck (0.10.0)
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test036.sh (1)
1-3
: Add a shebang for clarity.
To avoid potential shellcheck issues and ensure the script runs with the intended shell, add a shebang (e.g. #!/bin/bash) at the beginning.Suggested diff:
+#!/bin/bash
🧰 Tools
🪛 Shellcheck (0.10.0)
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test038.sh (1)
1-3
: Insert a Shebang for Consistency.
Adding a shebang line (e.g. #!/bin/bash) at the top of the file is advisable to resolve shellcheck warnings and explicitly indicate which shell should execute the script.Suggested diff:
+#!/bin/bash
🧰 Tools
🪛 Shellcheck (0.10.0)
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test022.sh (1)
1-3
: Insert a Shebang for Shell Specification.
A shebang (e.g. #!/bin/bash) should be added at the top of the file to ensure predictable behavior and to satisfy shellcheck that a specific shell is intended.Suggested diff:
+#!/bin/bash
🧰 Tools
🪛 Shellcheck (0.10.0)
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test037.sh (1)
1-3
: Add a Shebang Directive
Consider adding a shebang line (e.g., #!/bin/bash) at the very top of the script. This not only clarifies the intended interpreter but also resolves the Shellcheck warning (SC2148).🧰 Tools
🪛 Shellcheck (0.10.0)
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test028.sh (1)
1-3
: Add a Shebang Directive
It is recommended to add a shebang line (e.g., #!/bin/bash) at the top. This will ensure the script runs with the correct shell interpreter and address the static analysis suggestion (SC2148).🧰 Tools
🪛 Shellcheck (0.10.0)
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test029.sh (1)
1-3
: Add a Shebang Directive
Consider inserting a shebang line (e.g., #!/bin/bash) at the top to clarify the script’s intended shell, which also addresses the Shellcheck feedback.🧰 Tools
🪛 Shellcheck (0.10.0)
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test040.sh (1)
1-3
: Add a Shebang Directive
Including a shebang (e.g., #!/bin/bash) at the start of the file will clarify the shell context and prevent the static analysis warning.🧰 Tools
🪛 Shellcheck (0.10.0)
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test009.sh (1)
1-3
: Add a Shebang Directive
Please add a shebang (e.g., #!/bin/bash) at the top of the script to explicitly set the shell, addressing both clarity and the Shellcheck recommendation.🧰 Tools
🪛 Shellcheck (0.10.0)
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test010.sh (1)
1-3
: Add a shebang for proper shell execution.
It’s recommended to include a shebang line (e.g., "#!/bin/bash") at the top of the script. This avoids ambiguity about the shell being used and addresses the shellcheck warning.Suggested diff:
+#!/bin/bash
Place this line at the very beginning of the file.
🧰 Tools
🪛 Shellcheck (0.10.0)
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test051.sh (1)
1-3
: Specify the shell interpreter with a shebang.
Including a shebang line (e.g., "#!/bin/bash") will clearly define the script’s execution environment and resolve the shellcheck warning.Suggested diff:
+#!/bin/bash
Insert this at the top of the file.
🧰 Tools
🪛 Shellcheck (0.10.0)
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test031.sh (1)
1-3
: Add a shebang to declare the shell interpreter.
To avoid any ambiguity and adhere to best practices, add a shebang line (e.g., "#!/bin/bash") at the beginning of the script.Suggested diff:
+#!/bin/bash
Place this at the start of the file.
🧰 Tools
🪛 Shellcheck (0.10.0)
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test018.sh (1)
1-3
: Include a shebang for clarity.
Adding a shebang line (e.g., "#!/bin/bash") at the top will explicitly set the shell environment and comply with shellcheck recommendations.Suggested diff:
+#!/bin/bash
Insert this as the first line.
🧰 Tools
🪛 Shellcheck (0.10.0)
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test017.sh (1)
1-3
: Add a shebang to designate the shell.
It’s best practice to add a shebang line (e.g., "#!/bin/bash") at the top to specify the intended shell, thereby avoiding related shellcheck warnings.Suggested diff:
+#!/bin/bash
Add this at the beginning of the file.
🧰 Tools
🪛 Shellcheck (0.10.0)
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test020.sh (1)
1-3
: Add a shebang for reliable execution.
Consider adding a shebang line (e.g., "#!/bin/bash") at the very top so that the script runs in the intended shell and to address ShellCheck’s SC2148 warning.🧰 Tools
🪛 Shellcheck (0.10.0)
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test041.sh (1)
1-3
: Add a shebang for portability.
Including a shebang (for example, "#!/bin/bash") at the top will clarify which shell should run the script and resolve ShellCheck’s warning.🧰 Tools
🪛 Shellcheck (0.10.0)
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test033.sh (1)
1-3
: Add a shebang to comply with best practices.
A shebang line (e.g., "#!/bin/bash") should be added at the very top to clearly specify the intended interpreter and satisfy ShellCheck recommendations.🧰 Tools
🪛 Shellcheck (0.10.0)
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test042.sh (1)
1-1
: Add a shebang for proper script initialization.
Inserting a shebang (e.g., "#!/bin/bash") at the top will ensure the script is executed in the correct shell environment, improving readability and robustness.🧰 Tools
🪛 Shellcheck (0.10.0)
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test043.sh (1)
1-3
: Include a shebang for consistency.
To maintain consistency across all test scripts and to resolve ShellCheck warnings, please add a shebang line (e.g., "#!/bin/bash") at the beginning of the file.🧰 Tools
🪛 Shellcheck (0.10.0)
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test050.sh (1)
1-1
: Add Shebang to This Script
This new test file is missing a shebang, which is recommended for clear interpreter specification and improved portability.Proposed change:
+#!/bin/bash
🧰 Tools
🪛 Shellcheck (0.10.0)
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test025.sh (1)
1-1
: Add Shebang to This Script
For consistency and explicit shell usage, please add a shebang (e.g.,#!/bin/bash
) at the very start of this file.Proposed change:
+#!/bin/bash
🧰 Tools
🪛 Shellcheck (0.10.0)
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/runner.sh (1)
3-3
: Improve cd Command Robustness
Consider adding error handling to the directory change to catch potential failures. For example, modifying the command to include a fallback (using|| exit 1
) would improve reliability.Proposed change:
-cd "$(dirname "$0")" +cd "$(dirname "$0")" || exit 1🧰 Tools
🪛 Shellcheck (0.10.0)
[warning] 3-3: Use 'cd ... || exit' or 'cd ... || return' in case cd fails.
(SC2164)
tests/copytests/cases/test002.sh (1)
1-1
: Add Shebang to This Script
Please add a shebang (e.g.,#!/bin/bash
) at the beginning of this file to clearly specify the interpreter for this test.Proposed change:
+#!/bin/bash
🧰 Tools
🪛 Shellcheck (0.10.0)
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (55)
tests/copytests/cases/test000.sh
(1 hunks)tests/copytests/cases/test001.sh
(1 hunks)tests/copytests/cases/test002.sh
(1 hunks)tests/copytests/cases/test003.sh
(1 hunks)tests/copytests/cases/test004.sh
(1 hunks)tests/copytests/cases/test005.sh
(1 hunks)tests/copytests/cases/test006.sh
(1 hunks)tests/copytests/cases/test007.sh
(1 hunks)tests/copytests/cases/test008.sh
(1 hunks)tests/copytests/cases/test009.sh
(1 hunks)tests/copytests/cases/test010.sh
(1 hunks)tests/copytests/cases/test011.sh
(1 hunks)tests/copytests/cases/test012.sh
(1 hunks)tests/copytests/cases/test013.sh
(1 hunks)tests/copytests/cases/test014.sh
(1 hunks)tests/copytests/cases/test015.sh
(1 hunks)tests/copytests/cases/test016.sh
(1 hunks)tests/copytests/cases/test017.sh
(1 hunks)tests/copytests/cases/test018.sh
(1 hunks)tests/copytests/cases/test019.sh
(1 hunks)tests/copytests/cases/test020.sh
(1 hunks)tests/copytests/cases/test021.sh
(1 hunks)tests/copytests/cases/test022.sh
(1 hunks)tests/copytests/cases/test023.sh
(1 hunks)tests/copytests/cases/test024.sh
(1 hunks)tests/copytests/cases/test025.sh
(1 hunks)tests/copytests/cases/test026.sh
(1 hunks)tests/copytests/cases/test027.sh
(1 hunks)tests/copytests/cases/test028.sh
(1 hunks)tests/copytests/cases/test029.sh
(1 hunks)tests/copytests/cases/test030.sh
(1 hunks)tests/copytests/cases/test031.sh
(1 hunks)tests/copytests/cases/test032.sh
(1 hunks)tests/copytests/cases/test033.sh
(1 hunks)tests/copytests/cases/test034.sh
(1 hunks)tests/copytests/cases/test035.sh
(1 hunks)tests/copytests/cases/test036.sh
(1 hunks)tests/copytests/cases/test037.sh
(1 hunks)tests/copytests/cases/test038.sh
(1 hunks)tests/copytests/cases/test039.sh
(1 hunks)tests/copytests/cases/test040.sh
(1 hunks)tests/copytests/cases/test041.sh
(1 hunks)tests/copytests/cases/test042.sh
(1 hunks)tests/copytests/cases/test043.sh
(1 hunks)tests/copytests/cases/test044.sh
(1 hunks)tests/copytests/cases/test045.sh
(1 hunks)tests/copytests/cases/test046.sh
(1 hunks)tests/copytests/cases/test047.sh
(1 hunks)tests/copytests/cases/test048.sh
(1 hunks)tests/copytests/cases/test049.sh
(1 hunks)tests/copytests/cases/test050.sh
(1 hunks)tests/copytests/cases/test051.sh
(1 hunks)tests/copytests/cases/test052.sh
(1 hunks)tests/copytests/runner.sh
(1 hunks)tests/copytests/testutil.sh
(1 hunks)
🧰 Additional context used
🪛 Shellcheck (0.10.0)
tests/copytests/cases/test005.sh
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test036.sh
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test040.sh
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test012.sh
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test038.sh
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test023.sh
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test014.sh
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test000.sh
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test006.sh
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test011.sh
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test004.sh
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test015.sh
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test032.sh
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test030.sh
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test039.sh
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test024.sh
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test003.sh
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test051.sh
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test016.sh
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test013.sh
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test034.sh
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test037.sh
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test019.sh
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test021.sh
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test047.sh
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test022.sh
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test010.sh
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test042.sh
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test007.sh
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test049.sh
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test028.sh
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test025.sh
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test041.sh
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test020.sh
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test018.sh
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test050.sh
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test009.sh
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/testutil.sh
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test008.sh
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test033.sh
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test052.sh
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test035.sh
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/runner.sh
[warning] 3-3: Use 'cd ... || exit' or 'cd ... || return' in case cd fails.
(SC2164)
tests/copytests/cases/test045.sh
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test046.sh
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test026.sh
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test031.sh
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test048.sh
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test044.sh
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test017.sh
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test002.sh
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test027.sh
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test043.sh
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test029.sh
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test001.sh
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: Analyze (go)
- GitHub Check: Build for TestDriver.ai
🔇 Additional comments (65)
tests/copytests/cases/test030.sh (2)
9-9
: File Copy Command Testing
The command "wsh file copy baz/foo.txt ." is correctly invoked to test copying a file from a subdirectory to the current directory. Ensure that this command covers the intended corner cases as described in the PR objectives.
11-14
: File Existence Verification
The if-condition correctly checks for the existence of "foo.txt" in the current directory and outputs an error if the file is not found. For clarity, consider adding an inline comment explaining why this check is critical to the test case.tests/copytests/cases/test026.sh (3)
5-7
: Solid initial setup.
The use of "set -e" ensures that the script aborts on any command failure, and changing directories to "$HOME/testcp" establishes a controlled execution context. The creation of "foo.txt" is clear for setting up the test scenario.
9-10
: Validate expected failure condition.
The command "wsh file copy foo.txt baz/ >/dev/null 2>&1 && echo 'command should have failed' && exit 1" is written to expect a failure from the "wsh file copy" operation. This chaining ensures that if the copy unexpectedly succeeds, an error message is printed and the script exits with an error status. Make sure that this behavior is in line with the intended design of the command.
12-15
: Confirm non-creation of unintended file.
The check for the existence of "baz/foo.txt" correctly verifies that no file was created as a side effect of the failing copy command. This validation is crucial for covering the corner case described in the PR objectives.tests/copytests/cases/test016.sh (4)
4-4
: Use of "set -e" is Appropriate
Using "set -e" ensures that the script exits on any error, which is a good practice in test scripts.
6-7
: File Creation is Correct
The "touch foo.txt" command effectively creates the source file required for the test. This is clear and concise.
8-8
: Validation of Tilde Expansion in Copy Command
The command "wsh file copy ~/testcp/foo.txt/testcp/bar.txt" is designed to test tilde expansion. Ensure that the implementation of "wsh file copy" correctly handles the expansion of "" to the user's home directory.
10-13
: File Existence Check is Appropriate
The if-statement checking for the existence of "bar.txt" is an effective way to validate that the copy operation was successful. For extra robustness, you might also consider verifying file contents or permissions as additional checks.tests/copytests/cases/test027.sh (2)
4-7
: Test Setup is Clear and EffectiveThe use of “set -e” together with changing the directory to "$HOME/testcp" and creating the test file "foo.txt" correctly establishes the testing environment. Everything looks in order here.
8-8
: Command Execution is StraightforwardThe command "wsh file copy foo.txt baz" is used to validate that copying into a non-existing filename (not ending with a "/") creates a file rather than a directory. This aligns well with the test objective.
tests/copytests/cases/test047.sh (2)
10-10
: Validate the File Copy CommandThe command “wsh file copy foo///bar.txt baz//qux.txt” effectively tests the handling of extra slashes in file paths. This aligns well with the PR’s objective of covering edge cases in local copies.
12-15
: Confirm the Existence Check LogicThe verification block using “if [ ! -f baz/qux.txt ]; then … fi” correctly checks that the file was copied. If needed in later tests, you might extend this validation to include file content or checksum verification.
tests/copytests/cases/test015.sh (2)
4-7
: Test Setup Verification.
The commands "set -e", changing the directory to "$HOME/testcp", and creating "foo.txt" provide a simple and clear setup. Just ensure that "$HOME/testcp" exists before running this test or that a previous setup step creates it.
8-8
: Validate Tilde Expansion in the Copy Command.
The command "wsh file copy ~/testcp/foo.txt ~/testcp/bar.txt" is well-targeted to verify that tilde expansion works correctly in both source and destination paths.tests/copytests/cases/test045.sh (2)
11-11
: Validate the File Copy Command's BehaviorThe command "wsh file copy -r foo qux" is expected to copy the entire "foo" directory into "qux", maintaining the directory structure (leading to the file being at "qux/foo/bar/baz.txt"). Confirm that this behavior aligns with the intended design of the command.
13-16
: Verify File Existence Post-CopyThe existence check using "if [ ! -f qux/foo/bar/baz.txt ]" serves as a clear validation for the test. It is effective in ensuring that the nested file was successfully copied. The error message and exit code provide a good diagnostic for failure.
tests/copytests/cases/test019.sh (2)
8-8
: Validate Failure Handling of Copy Command
The command correctly expects the file copy operation to fail (i.e. copying a file to itself when destination expands to the same path) by using the “&&” chain. This approach is acceptable for these tests. For enhanced clarity in more complex scenarios, you might later consider using an explicit “if” block to check the exit code.
10-13
: Confirm File Existence Post Copy Attempt
The conditional check correctly verifies that “foo.txt” still exists, ensuring that the failed copy operation did not remove the original file.tests/copytests/cases/test035.sh (2)
1-3
: Descriptive Comments for Test Intent
The comments on lines 1–3 clearly describe the purpose of the test: ensuring that copying an empty directory to a non-existent directory (with a trailing slash and without the recursive flag) fails as expected.🧰 Tools
🪛 Shellcheck (0.10.0)
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
10-13
: Validation of Target Directory Non-Existence
The conditional check on lines 10–13 correctly verifies that the directory "baz" does not exist after the failed copy command. This logic effectively captures the intended failure scenario of the test.tests/copytests/cases/test048.sh (3)
4-10
: Test setup is clear and well-structured.
The block that sets the execution to exit on error, navigates to the test directory, and sets up subdirectories and test files is straightforward and aligns with the test objectives.
11-16
: The failure verification and output file check are correctly implemented.
The command "wsh file copy . ../baz >/dev/null 2>&1 && echo 'command should have failed' && exit 1" properly asserts that the copy operation should fail, and the subsequent check ensures that no unintended file ("baz/bar.txt") is created.
1-3
: 🛠️ Refactor suggestionAdd a shebang line for explicit shell specification.
Including a shebang (for example, "#!/bin/bash") at the top of the script ensures that it runs with the intended shell interpreter. This resolves the static analysis warning (SC2148) and makes the script’s execution environment explicit.Proposed diff:
+#!/bin/bash
✅ Verification successful
Action: Add the shebang line to tests/copytests/cases/test048.sh
The file currently starts with only comments and doesn’t specify a shell interpreter. Adding a shebang (e.g.,
#!/bin/bash
) at the top ensures that the script runs with the intended shell and resolves the SC2148 static analysis warning.
- File: tests/copytests/cases/test048.sh – add
#!/bin/bash
at the very top.🧰 Tools
🪛 Shellcheck (0.10.0)
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
tests/copytests/cases/test044.sh (1)
10-10
: Core Command Execution is Correct
The command "wsh file copy -r foo qux" directly tests the recursive copying functionality as intended.tests/copytests/cases/test049.sh (2)
11-12
: Validate Copy Command Execution
The core command "wsh file copy -r . ../baz" is clearly being exercised here. With "set -e" in effect, any failure will abort the script. Ensure this behavior aligns with the overall test strategy, and consider verifying additional aspects (like file content or permissions) if relevant for your use case.
14-17
: Effective Verification of Copy Outcome
The test correctly verifies that "baz/bar.txt" exists after the copy operation. This conditional check is straightforward and meets the intended purpose.tests/copytests/cases/test039.sh (2)
4-7
: Environment Setup is ClearThe commands setting the testing environment (using "set -e", changing directory, creating "bar", and touching "bar/foo.txt") are straightforward and effectively prepare for the test.
9-9
: Validate Failure of Non-Recursive CopyThe command on line 9 correctly uses output redirection and a conditional chain (with &&) to check that the "wsh file copy" operation fails when copying a directory without the "-r" flag. This is an appropriate pattern to detect unexpected command success.
tests/copytests/cases/test003.sh (1)
9-12
: Verify Source File Persistence
The test validates that the source file (foo.txt) still exists after running the copy command. Ensure that the expected behavior forwsh file copy
is indeed to preserve the source file.tests/copytests/cases/test000.sh (1)
7-13
: Test Logic Validation
This test confirms that the original file (foo.txt) is not removed after the copy operation. If the goal is solely to check source persistence, this is fine; however, if full verification is desired, you might also want to check that the destination file (bar.txt) is created in another test.tests/copytests/cases/test004.sh (1)
9-12
: Destination File Existence Check
The script correctly verifies that the destination file (bar.txt) exists after the copy operation, which aligns with the test’s objective of ensuring that the copy was successful.tests/copytests/testutil.sh (1)
11-13
: Cleanup Function Validation
The cleanup_testcp function uses a fallback withrmdir
afterrm -rf
, which is acceptable for ensuring the directory is removed. No changes are needed here.tests/copytests/cases/test001.sh (1)
9-12
: Destination File Verification
This test appropriately checks that the destination file (bar.txt) exists after the copy operation, which confirms that the command executed as expected.tests/copytests/cases/test006.sh (1)
4-13
: Test Logic and StructureThe test case is clear and effective. It sets the environment with "set -e", navigates to the test directory, creates "foo.txt", runs the copy command (using a destination path starting with "./"), and then checks for the existence of "bar.txt".
tests/copytests/cases/test012.sh (1)
4-13
: Test Case ValidationThis test properly changes to the designated directory, creates a source file, and uses tilde expansion in the source path ("~/testcp/foo.txt") when invoking the copy command. The subsequent check for the existence of "bar.txt" confirms that the destination file was created successfully.
tests/copytests/cases/test011.sh (1)
4-13
: Test Validation for Source PreservationThe test effectively verifies that after the copy command (using tilde expansion in the source path), the original file "foo.txt" continues to exist. This confirms that the copy operation does not inadvertently remove the source file.
tests/copytests/cases/test014.sh (1)
4-13
: Destination File Existence CheckThe test is well structured; it sets up the environment, creates "foo.txt", uses a tilde expansion for the destination path, and then checks that "bar.txt" exists after the copy. This clearly validates that the destination file is properly created during the copy operation.
tests/copytests/cases/test008.sh (1)
4-13
: Test Case Verification and Environment Setup.
The test flow is clear and correctly sets "exit on error" mode, changes to the test directory, creates the source file, executes the copy command, and verifies the destination file’s existence. Consider adding cleanup steps if this test modifies shared state.tests/copytests/cases/test021.sh (1)
4-14
: Valid Test Setup for Renamed File Copy Operation.
The script properly sets the test environment by changing directories, creating the file, and setting up a subdirectory before using the copy command with a new filename. It correctly verifies the existence of "baz/bar.txt". Consider ensuring that any temporary files or directories are cleaned up after the test.tests/copytests/cases/test023.sh (1)
4-14
: Test Confirmation for Copying into a Directory with Trailing Slash.
The script successfully verifies that copying "foo.txt" into an existing directory (with a trailing slash) results in the file being placed inside the directory. For more robust testing, you may also consider verifying file contents if applicable.tests/copytests/cases/test032.sh (1)
4-13
: Test Validity for Recursive Directory Copy.
The script effectively tests the recursive copy of an empty directory using the "-r" flag and verifies that the target directory "bar" exists. It would be beneficial to ensure test isolation by cleaning up any directories created during the test.tests/copytests/cases/test024.sh (1)
4-14
: Appropriate Testing for Copying into a Directory Without Trailing Slash.
The test script correctly handles the scenario of copying "foo.txt" into an existing directory without a trailing slash and verifies that the file is placed inside "baz". Consider incorporating cleanup logic to maintain a clean test environment.tests/copytests/cases/test034.sh (1)
4-12
: Test Logic Verification.
The script sets strict error handling with “set -e”, navigates to the test directory, creates the “bar” directory, and uses the recursive copy flag correctly. The conditional check for the existence of “baz” properly validates that the copy operation succeeded.tests/copytests/cases/test046.sh (1)
4-14
: Test Case Validation.
The script accurately sets up the environment by changing to “$HOME/testcp”, creating the “foo” directory, and generating the file “bar.txt” inside it. The copy command “wsh file copy foo///bar.txt .” is tested with an unconventional path format, and the subsequent check confirms that “bar.txt” exists in the current directory.tests/copytests/cases/test036.sh (1)
4-13
: Test Logic Verification.
The test script effectively sets error handling, switches to the designated test directory, creates the “bar” directory, and then executes the copy command with the recursive flag to copy “bar” into “baz/”. The subsequent directory existence check confirms proper behavior.tests/copytests/cases/test038.sh (1)
4-13
: Proper Test Implementation.
The script sets the environment with “set -e”, navigates to “$HOME/testcp”, creates the “bar” directory, and then uses “wsh file copy -r bar baz//” to test copying with an unusual target path format. The check for the existence of “baz” confirms that the copy operation completed successfully.tests/copytests/cases/test022.sh (1)
4-14
: Test Case Logic Review.
The test sets up the necessary environment by navigating to “$HOME/testcp”, creating “foo.txt” and the directory “baz”, and then performing the copy operation “wsh file copy foo.txt baz/foo.txt”. The following existence check for “baz/foo.txt” confirms that the file copy has been executed correctly.tests/copytests/cases/test037.sh (1)
4-13
: Test Case Validation
The test case correctly sets up the environment by navigating to the test directory, creating the source directory (bar), and performing the recursive copy operation using the double slash syntax (“bar//”). It then properly validates that the target directory (baz) is created.tests/copytests/cases/test028.sh (1)
4-17
: Test Case Validation
The script sets the error mode with “set -e” and correctly establishes the testing environment by creating “foo.txt” and the “baz” directory. The copy operation (copying ../foo.txt into the current directory) and subsequent check for “baz/foo.txt” ensure the copy command's correctness.tests/copytests/cases/test029.sh (1)
4-17
: Test Case Validation
The test sets up the environment by creating the “baz” directory and a file inside it. The command “wsh file copy foo.txt ..” is executed in “baz” and subsequently, the test verifies that “foo.txt” exists in the parent directory. The logic is direct and effective.tests/copytests/cases/test040.sh (1)
4-14
: Test Case Validation
This test successfully performs a recursive copy of a directory that contains a file. The script creates “bar”, adds “foo.txt” into it, executes the copy command with the “-r” flag, and then validates that “baz/foo.txt” exists. The test is clear and achieves its purpose.tests/copytests/cases/test009.sh (1)
4-13
: Test Case Validation and Failure Handling
The script is designed to verify that attempting to copy a file onto itself fails as expected. It runs the copy command with redirection to suppress output, checks for the error condition, and finally confirms that the original file still exists. The logic is robust and clear.tests/copytests/cases/test010.sh (1)
4-14
: Validate self-copy failure and file integrity.
The test logic correctly ensures that attempting to copy a file to itself (using a different literal path) fails, and that the original file remains intact.tests/copytests/cases/test051.sh (1)
4-17
: Ensure recursive copy behavior and consider cleanup.
The test properly validates that using the "-r" flag on a directory copy creates the expected target directory and file. Consider verifying that any temporary directories created (like "baz") are cleaned up either within the test or via an external cleanup routine to maintain test isolation.tests/copytests/cases/test031.sh (1)
4-14
: Verify failure when copying without the recursive flag.
This test successfully asserts that copying an empty directory without "-r" fails and that no target directory ("bar") is created.tests/copytests/cases/test018.sh (1)
4-14
: Confirm failure of self-copy with tilde expansion.
The test correctly checks that copying a file to itself—using an absolute path via tilde expansion—fails, and that the original file still exists afterward.tests/copytests/cases/test017.sh (1)
4-14
: Ensure self-copy failure with tilde for destination resolution.
The test is correctly structured to confirm that copying a file onto itself (with tilde expansion in the destination) fails, and that the original file remains unaltered.tests/copytests/cases/test020.sh (1)
8-8
: Confirm failure behavior is correctly detected.
The command attempts to copy a file to itself (with environment variable expansion) and uses a short-circuit “&&” to print an error and exit if, unexpectedly, it succeeds. This is a clear approach—but verify that the redirection and exit conditions cover all failure scenarios.tests/copytests/cases/test041.sh (1)
10-11
: Verify command syntax consistency.
This script uses the command "wsh file -r bar baz" to perform a recursive directory copy. Please double-check that this syntax (omitting the explicit "copy" keyword) aligns with the intended behavior and is consistent with other test cases.tests/copytests/cases/test043.sh (1)
10-11
: Confirm destination directory behavior.
This test uses "wsh file copy -r bar baz/."—the dot (".") at the end of the destination indicates that the contents of "bar" should be copied into "baz." Verify that this behavior aligns with expectations and is consistent with other tests.tests/copytests/cases/test050.sh (1)
10-15
: Verify the Failure Behavior
The test is designed to run a copy command that should fail (copying a directory without the -r flag) and then confirms that no file (baz/bar.txt) has been unexpectedly created. Ensure that this failure condition and subsequent check accurately reflect the intended behavior of thewsh file copy
command.tests/copytests/cases/test025.sh (1)
5-11
: Clear Test Case Logic and Documentation
The script clearly sets up the environment, executes the copy command, and verifies that the file was successfully copied into the new (previously non-existent) directory. The comments effectively describe the test’s intent.tests/copytests/runner.sh (1)
6-15
: Test Case Loop and Error Reporting
The loop that iterates over the test case files is well-constructed. It usessetup_testcp
andcleanup_testcp
to manage the environment and captures any errors from the test execution. The conditional printing of PASS/FAIL messages is readable and effective.tests/copytests/cases/test002.sh (1)
11-18
: Verify File Integrity Check
The MD5 checksum comparison is an effective method to ensure that the file copy operation preserved all the contents identically. Consider adding more verbose logging on failure to aid debugging if needed.
# copy a file where destination starts with ./ | ||
# ensure the source file exists | ||
|
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.
🛠️ Refactor suggestion
Add Shebang for Script Clarity
It's recommended to add a shebang line (e.g. #!/bin/bash) at the top of the file to explicitly specify the interpreter. This helps avoid any ambiguity regarding the target shell and resolves the shellcheck warning (SC2148).
🧰 Tools
🪛 Shellcheck (0.10.0)
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
@@ -0,0 +1,13 @@ | |||
# copy an empty directory to a non-existing directory ending with / without -r flag |
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.
🛠️ Refactor suggestion
Add a Shebang Directive
It is best practice to include a shebang (e.g. #!/usr/bin/env bash) at the very top of the script to clearly indicate the intended shell interpreter. This helps avoid potential ambiguities when the script is executed in different environments.
Suggested diff:
+#!/usr/bin/env bash
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
# copy an empty directory to a non-existing directory ending with / without -r flag | |
#!/usr/bin/env bash | |
# copy an empty directory to a non-existing directory ending with / without -r flag |
🧰 Tools
🪛 Shellcheck (0.10.0)
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
# copy a doubly nested directory containing a file to a non-existant directory with the -r flag | ||
# ensure this succeeds and the new files exist with the first directory renamed | ||
|
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.
🛠️ Refactor suggestion
Add a Shebang Line and Fix Spelling Errors
The script currently does not specify a shell interpreter, which can lead to inconsistent execution environments. Adding a shebang (e.g., "#!/bin/bash") helps clarify the intended shell. Additionally, correct the typo "non-existant" to "non-existent" for clarity.
Proposed diff:
+#!/bin/bash
-# copy a doubly nested directory containing a file to a non-existant directory with the -r flag
+# copy a doubly nested directory containing a file to a non-existent directory with the -r flag
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
# copy a doubly nested directory containing a file to a non-existant directory with the -r flag | |
# ensure this succeeds and the new files exist with the first directory renamed | |
#!/bin/bash | |
# copy a doubly nested directory containing a file to a non-existent directory with the -r flag | |
# ensure this succeeds and the new files exist with the first directory renamed |
🧰 Tools
🪛 Shellcheck (0.10.0)
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
if [ ! -f foo.txt ]; then | ||
echo "foo.txt does not exist" | ||
exit 1 | ||
fi |
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.
Improve validation checks for copy success
The current conditional block only checks for the existence of "foo.txt", ensuring that the source file was not removed. However, to fully validate the copy operation, you should also verify the existence (and optionally the content integrity) of "bar.txt".
For example, you could add the following snippet after line 9:
+if [ ! -f bar.txt ]; then
+ echo "bar.txt does not exist"
+ exit 1
+fi
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
if [ ! -f foo.txt ]; then | |
echo "foo.txt does not exist" | |
exit 1 | |
fi | |
if [ ! -f bar.txt ]; then | |
echo "bar.txt does not exist" | |
exit 1 | |
fi | |
if [ ! -f foo.txt ]; then | |
echo "foo.txt does not exist" | |
exit 1 | |
fi |
@@ -0,0 +1,12 @@ | |||
# copy a file to one with a different name |
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.
🛠️ Refactor suggestion
Missing Shebang Directive
Consider adding a shebang (e.g., #!/bin/bash) at the beginning of the file to specify the shell interpreter and improve portability.
🧰 Tools
🪛 Shellcheck (0.10.0)
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
@@ -0,0 +1,12 @@ | |||
# copy a file where source starts with ./ |
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.
🛠️ Refactor suggestion
Missing Shebang Directive
Adding a shebang (e.g., #!/bin/bash) at the top will ensure clarity regarding the script’s execution environment and address static analysis hints.
🧰 Tools
🪛 Shellcheck (0.10.0)
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
@@ -0,0 +1,12 @@ | |||
# copy a file to one with a different name |
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.
🛠️ Refactor suggestion
Missing Shebang Directive
A shebang line (e.g., #!/bin/bash) at the top of the script is recommended to clearly define the interpreter and avoid any shell compatibility issues.
🧰 Tools
🪛 Shellcheck (0.10.0)
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
|
||
FOO_MD5=$(md5sum foo.txt | cut -d " " -f1) | ||
BAR_MD5=$(md5sum bar.txt | cut -d " " -f1) | ||
if [ $FOO_MD5 != $BAR_MD5 ]; then |
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.
🛠️ Refactor suggestion
Quote Variables in Conditional Check
To avoid potential word-splitting issues or errors when variables are empty, ensure that the MD5 variables are quoted in the conditional statement.
Proposed change:
-if [ $FOO_MD5 != $BAR_MD5 ]; then
+if [ "$FOO_MD5" != "$BAR_MD5" ]; then
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
if [ $FOO_MD5 != $BAR_MD5 ]; then | |
if [ "$FOO_MD5" != "$BAR_MD5" ]; then |
Change file to fail Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
change file to fail Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
This adds tests for the corner cases of the
wsh file copy
command. At the moment, these focus on local copies since they are more easily replicated.