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

fix: broken TestHardcodedIncludeDirectiveDDOS2 on windows #1136

Merged

Conversation

jabdr
Copy link
Contributor

@jabdr jabdr commented Aug 24, 2024

This is a small fix for the TestHardcodedIncludeDirectiveDDOS2 on windows.

Windows refuses to delete files as long as the file descriptor is open. Closing the temporary file fixes this issue and go test is able to cleanup the files.

@jabdr jabdr marked this pull request as ready for review August 24, 2024 17:15
@jabdr jabdr requested a review from a team as a code owner August 24, 2024 17:15
Copy link

codecov bot commented Aug 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.91%. Comparing base (4ff1f76) to head (9e82d9e).
Report is 81 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1136      +/-   ##
==========================================
+ Coverage   82.72%   83.91%   +1.19%     
==========================================
  Files         162      166       +4     
  Lines        9080     7891    -1189     
==========================================
- Hits         7511     6622     -889     
+ Misses       1319     1019     -300     
  Partials      250      250              
Flag Coverage Δ
default 83.91% <ø> (+6.08%) ⬆️
examples 83.91% <ø> (+57.48%) ⬆️
ftw 83.91% <ø> (+36.55%) ⬆️
ftw-multiphase 83.91% <ø> (+34.37%) ⬆️
tinygo 83.91% <ø> (+8.51%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -169,6 +169,7 @@ func TestHardcodedIncludeDirectiveDDOS2(t *testing.T) {
if err != nil {
t.Fatal(err)
}
tmpFile2.Close()
Copy link
Member

Choose a reason for hiding this comment

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

shouldn't we assert errors on tmpFile2.Close()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@jabdr jabdr force-pushed the windows-fix-TestHardcodedIncludeDirectiveDDOS2 branch from 7b25147 to 03cce15 Compare August 27, 2024 11:57
Copy link
Member

@jcchavezs jcchavezs left a comment

Choose a reason for hiding this comment

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

Thanks! I think it is way easier to create the file on before hand instead of relying on an existing unrelated file in the system. You can do os.CreateTemp(t.TempDir(), "existing.txt"). This could be merged right away after that.

@jabdr jabdr force-pushed the windows-fix-TestHardcodedIncludeDirectiveDDOS2 branch from 03cce15 to 87ddf45 Compare August 28, 2024 19:03
@jabdr
Copy link
Contributor Author

jabdr commented Aug 28, 2024

@jcchavezs I am not sure what you mean. I do not want to touch the existing code in this PR, just fix the missing Close statement (which is also required with os.CreateTemp).

@jcchavezs jcchavezs merged commit 5eb9b53 into corazawaf:main Sep 23, 2024
8 checks passed
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.

4 participants