-
-
Notifications
You must be signed in to change notification settings - Fork 140
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
Fix Windows tests, verify in CI #394
Conversation
Adds a Windows test run to CI. Go setup relies on GHA for this because Hermit doesn't yet support Windows.
assert.NotNil does not exist.
If we couldn't read because the source is a directory, override the original error message.
@@ -12,16 +12,30 @@ jobs: | |||
- name: Checkout code | |||
uses: actions/checkout@v2 | |||
- name: Init Hermit | |||
run: ./bin/hermit env -r >> $GITHUB_ENV | |||
run: ./bin/hermit env -r >> "$GITHUB_ENV" |
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.
Quoting here was suggested by staticcheck.
I can remove it if you'd prefer not to have that in this change.
@@ -1,8 +1,8 @@ | |||
module github.com/alecthomas/kong | |||
|
|||
require ( | |||
github.com/alecthomas/assert/v2 v2.1.0 | |||
github.com/alecthomas/repr v0.1.0 | |||
github.com/alecthomas/assert/v2 v2.4.1 |
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.
The upgrade was required for the assert.IsError function.
@@ -514,15 +515,16 @@ func TestExistingFileMapperDefaultMissing(t *testing.T) { | |||
} | |||
var cli CLI | |||
p := mustNew(t, &cli) | |||
file := "testdata/file.txt" | |||
file := filepath.Join("testdata", "file.txt") |
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.
OS-specific filepath separator for string matching later.
@@ -632,8 +638,7 @@ func TestMapperPlaceHolder(t *testing.T) { | |||
assert.Contains(t, b.String(), "--flag=/a/b/c") | |||
} | |||
|
|||
type testMapperWithPlaceHolder struct { | |||
} | |||
type testMapperWithPlaceHolder struct{} |
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.
oops. this snuck in from gofumpt.
I can revert this line if you care about the difference.
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.
Looks great, thanks!
@@ -33,11 +33,12 @@ func TestWindowsFileMapper(t *testing.T) { | |||
p := mustNew(t, &cli) | |||
_, err := p.Parse([]string{"testdata\\file.txt"}) | |||
assert.NoError(t, err) | |||
assert.NotNil(t, cli.File) | |||
assert.True(t, cli.File != nil, "File should not be nil") |
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.
This is fine, but you should be able to use assert.NotZero()
here if you prefer.
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.
🤦 Doh. I completely blanked on that. "Hm, there's no NotNil. Guess that's not a covered use case."
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.
Fixed here #396
Annoying that it takes 1m just to run a test that takes 1s, but that's Windows life for you I guess. |
Indeed. Windows runners take a bit longer on GitHub. Although following this first run, it should have cached the dependencies so it'll take slightly less. AFAIK, the only way to make that go faster is pay GH money, which makes sense but also not worth it for an open source project. |
Follow up to alecthomas#394, specifically [this comment][1]. [1]: alecthomas#394 (comment)
Follow up to #394, specifically [this comment][1]. [1]: #394 (comment)
This adds testing against Windows to CI.
Hermit doesn't support Windows,
so the setup for that is done with GitHub Actions.
The following additional fixes were needed:
This is less informative on Windows when the source is a directory:
"Invalid function."
To fix this, we now assert that errors match
os.ErrNotExist
.This handles system-specific variations in the error message.