Skip to content
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

Redirections Extension #75

Merged
merged 33 commits into from
Dec 20, 2024
Merged

Redirections Extension #75

merged 33 commits into from
Dec 20, 2024

Conversation

ryan-gang
Copy link
Collaborator

No description provided.

@ryan-gang ryan-gang self-assigned this Dec 18, 2024
This commit introduces a new `MultiLineAssertion` type in `multi_line_assertion.go`, which allows for asserting that multiple lines of output match against an array of expected strings or regex patterns. The implementation includes methods for inspecting the assertion and running the validation against the screen state, enhancing the testing capabilities for multi-line outputs.
This commit introduces a new `FileContentAssertion` type in `file_content_assertion.go`, which allows for verifying that a specified file contains the expected content. The implementation includes methods for inspecting the assertion and executing the validation, enhancing the testing capabilities for file content checks.
When the outputFilePath collides with another same path outputs will no longer match cleanly
This commit introduces the `stage_r3` test, which validates shell behavior for redirected file content and directory listing handling via `ls` and `cat` commands. It sets up required random directories, files, and test cases, ensuring proper assertions and cleanup. The implementation is foundational for future expansion of test scenarios.

Signed-off-by: Ryan Gang <[email protected]>
…ling

This commit updates the `stage_r3` test to include additional command reflection and response validation for multi-line outputs. It introduces new commands to echo content into files and validates the output using the `CommandWithMultilineResponseTestCase`. The changes improve the robustness of the test by ensuring that multiple lines of output are correctly captured and asserted, enhancing overall test coverage for shell command handling.
This commit introduces a new function, `getShortRandomDirectories`, in `internal/utils.go` that generates a specified number of random directory paths and creates them in the `/tmp` directory. The function utilizes elements from the `SMALL_WORDS` array to form directory names and handles errors during directory creation, improving the utility of the codebase for generating temporary directories.
This commit refactors the directory cleanup process in the `stage_r1`, `stage_r2`, `stage_r3`, and `stage_r4` test files by introducing a new `cleanupDirectories` function. This change replaces the individual `defer os.RemoveAll(dir)` calls with a single deferred call to `cleanupDirectories(dirs)`, improving code readability and maintainability across the test implementations.
This commit refactors the `stage_r1` test by consolidating command definitions and improving variable assignments for clarity. The changes include replacing multiple `strings.Join` calls with direct variable assignments for random words, and updating command strings to reflect the new output file paths. This enhances code readability and maintains consistency in command execution across the test cases.
This commit refactors the `testR1` function in `stage_r1.go` by streamlining the creation and execution of command test cases. The changes include consolidating variable assignments for command reflection and response test cases, improving readability and reducing redundancy. This enhances the clarity of the test logic while maintaining the functionality of command execution and output validation.
This commit refactors the `testR2` function by consolidating variable assignments and improving command test case structure. Key changes include replacing multiple `strings.Join` calls with direct assignments for random words, updating the method for generating random words, and enhancing the clarity of command definitions. These improvements enhance code readability and maintain the functionality of command execution and output validation.
… and enhancing random word generation

This commit refactors the `testR3` function in `stage_r3.go` by consolidating variable assignments and improving the structure of command test cases. Key changes include replacing multiple variable declarations with tuple assignment for clarity, updating the method for generating random words to use `RandomElementsFromArray`, and streamlining command definitions. These enhancements improve code readability and maintain the functionality of command execution and output validation.
… and improving random word generation

This commit refactors the `testR4` function in `stage_r4.go` by consolidating variable assignments and enhancing the structure of command test cases. Key changes include using tuple assignment for `stageDir` and `lsDir`, updating the random word generation method to `RandomElementsFromArray`, and streamlining command definitions. These improvements enhance code readability while maintaining the functionality of command execution and output validation.
This commit refactors the `testR2` function in `stage_r2.go` by updating the way error messages are constructed and handled. Key changes include modifying the message formatting to ensure proper encapsulation of the file name in quotes, and adjusting the expected output to reflect this change. These improvements enhance code clarity and maintain the functionality of command execution and output validation.
@ryan-gang ryan-gang merged commit 9b8cc3d into main Dec 20, 2024
2 checks passed
@ryan-gang ryan-gang deleted the redirections branch December 20, 2024 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant