fix(e2e): replace bash-specific [[ with POSIX [ for OSTYPE check#288
Open
whg517 wants to merge 1 commit into
Open
fix(e2e): replace bash-specific [[ with POSIX [ for OSTYPE check#288whg517 wants to merge 1 commit into
whg517 wants to merge 1 commit into
Conversation
Chainsaw executes scripts with /usr/bin/sh (dash on Ubuntu), which does not support [[ or ==. Also add linux-musl (Alpine) variant.
There was a problem hiding this comment.
Pull request overview
This PR updates a Chainsaw E2E test script to avoid bash-specific conditional syntax so it can run under /bin/sh (dash), specifically for choosing the correct date invocation on different OSes.
Changes:
- Replaces
[[ ... ]]with POSIX[tests. - Replaces bash pattern matching (
darwin*,linux-gnu*) with equality checks forOSTYPEvalues.
Comments suppressed due to low confidence (1)
test/e2e/chainsaw/pod-expires/chainsaw-test.yaml:24
- The new checks use exact string equality (e.g.,
OSTYPE = darwin/linux-gnu) butOSTYPEcommonly includes suffixes (e.g.,darwin20.0,linux-gnuwith additional qualifiers), which the previousdarwin*/linux-gnu*pattern handled. If you keep usingOSTYPE, use a POSIX pattern match viacase(or another portable approach) so macOS/Linux variants still match.
if [ "$OSTYPE" = "linux-gnu" ] || [ "$OSTYPE" = "linux-musl" ]; then
NOW_AFTER_5s=$(date -d "+5 seconds" -u +"%Y-%m-%dT%H:%M:%SZ")
elif [ "$OSTYPE" = "darwin" ]; then
NOW_AFTER_5s=$(date -v+5S -u +"%Y-%m-%dT%H:%M:%SZ")
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+21
to
25
| if [ "$OSTYPE" = "linux-gnu" ] || [ "$OSTYPE" = "linux-musl" ]; then | ||
| NOW_AFTER_5s=$(date -d "+5 seconds" -u +"%Y-%m-%dT%H:%M:%SZ") | ||
| elif [[ "$OSTYPE" == "darwin"* ]]; then | ||
| elif [ "$OSTYPE" = "darwin" ]; then | ||
| NOW_AFTER_5s=$(date -v+5S -u +"%Y-%m-%dT%H:%M:%SZ") | ||
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Chainsaw uses /usr/bin/sh (dash). Replace [[ with [ and == with = for OSTYPE detection.