Skip to content

Conversation

@thaJeztah
Copy link
Member

@thaJeztah thaJeztah commented Jul 4, 2024

Trying to make the logic slightly clearer, and adding a custom message for the skip,

Before this:

=== RUN   TestSplitCpArg/absolute_path_with_drive
    cp_test.go:184: tc.os == "windows" && runtime.GOOS != "windows" || tc.os == "linux" && runtime.GOOS == "windows"

After this:

=== RUN   TestSplitCpArg/absolute_path_with_drive
    cp_test.go:184: skipping windows test on non-windows platform

@thaJeztah thaJeztah added status/2-code-review area/testing kind/refactor PR's that refactor, or clean-up code labels Jul 4, 2024
@thaJeztah thaJeztah added this to the 28.0.0 milestone Jul 4, 2024
@thaJeztah thaJeztah self-assigned this Jul 4, 2024
@codecov-commenter
Copy link

codecov-commenter commented Jul 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 61.48%. Comparing base (5aae44b) to head (88896ee).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #5230   +/-   ##
=======================================
  Coverage   61.48%   61.48%           
=======================================
  Files         298      298           
  Lines       20813    20813           
=======================================
  Hits        12797    12797           
  Misses       7104     7104           
  Partials      912      912           

@thaJeztah thaJeztah requested a review from vvoland July 4, 2024 14:02
@thaJeztah
Copy link
Member Author

Let me know if you like this better, @vvoland (happy to update)

tc := tc
t.Run(tc.doc, func(t *testing.T) {
skip.If(t, tc.os == "windows" && runtime.GOOS != "windows" || tc.os == "linux" && runtime.GOOS == "windows")
nonMatchingPlatform := tc.os == "windows" && runtime.GOOS != "windows" || tc.os == "unix" && runtime.GOOS == "windows"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was mostly concerned about splitting the OR'd parts into a separate variables to be honest 😅

    a := tc.os == "windows" && runtime.GOOS != "windows"
    b := tc.os == "unix" && runtime.GOOS == "windows"
    skip.If(t, a || b)

Mostly because it's easier to wrap your head about the end-result by looking at each of them separately, instead of trying to parse the whole 4 product expression.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Split it over 2 checks (I tried to avoid the skip.If(t, a || b) because the output looks weird in the logs 😂

But again; happy to change if you prefer it differently ❤️

Trying to make the logic slightly clearer, and adding a custom
message for the skip,

Before this:

    === RUN   TestSplitCpArg/absolute_path_with_drive
        cp_test.go:184: tc.os == "windows" && runtime.GOOS != "windows" || tc.os == "linux" && runtime.GOOS == "windows"

After this:

    === RUN   TestSplitCpArg/absolute_path_with_drive
	cp_test.go:184: skipping windows test on non-windows platform

Signed-off-by: Sebastiaan van Stijn <[email protected]>
Copy link
Collaborator

@vvoland vvoland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM ❤️

@vvoland vvoland merged commit be6a415 into docker:master Jul 5, 2024
@thaJeztah thaJeztah deleted the clean_skip branch July 5, 2024 08:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/testing kind/refactor PR's that refactor, or clean-up code status/2-code-review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants