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

Use unique temp dirs in unit tests #3494

Merged
merged 5 commits into from
Feb 21, 2018
Merged

Conversation

ethantkoenig
Copy link
Member

@ethantkoenig ethantkoenig commented Feb 12, 2018

Using a fixed directory causes problems if you run tests in parallel.

Using a fixed directory may have also caused tests to be flaky (e.g. https://drone.gitea.io/go-gitea/gitea/3530/8).

@codecov-io
Copy link

codecov-io commented Feb 12, 2018

Codecov Report

Merging #3494 into master will decrease coverage by 0.01%.
The diff coverage is 14.28%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3494      +/-   ##
==========================================
- Coverage   35.74%   35.72%   -0.02%     
==========================================
  Files         284      284              
  Lines       40778    40792      +14     
==========================================
- Hits        14576    14574       -2     
- Misses      24041    24054      +13     
- Partials     2161     2164       +3
Impacted Files Coverage Δ
models/unit_tests.go 69.02% <14.28%> (-9.77%) ⬇️
models/repo_list.go 65.62% <0%> (-1.57%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2f5c1ba...9ba38f8. Read the comment docs.

@tboerger tboerger added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Feb 12, 2018
Copy link
Member

@jonasfranz jonasfranz left a comment

Choose a reason for hiding this comment

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

Code looks good to me. But I haven't tested it yet.

@lafriks
Copy link
Member

lafriks commented Feb 12, 2018

Does integration tests also reuse these directories?

@ethantkoenig
Copy link
Member Author

@lafriks No

@lafriks
Copy link
Member

lafriks commented Feb 12, 2018

But we don't run tests in parallel I think

@ethantkoenig
Copy link
Member Author

@lafriks I know, but

  1. There's no reason not to use unique dirs, and
  2. I don't know how else to explain the spurious test failures we've been seeing

@lafriks
Copy link
Member

lafriks commented Feb 12, 2018

@ethantkoenig problem with this is that these directories will be left undeleted I think

@ethantkoenig
Copy link
Member Author

@lafriks Good point, fixed

@lafriks
Copy link
Member

lafriks commented Feb 12, 2018

@ethantkoenig as for 2nd point - To me it looks like something keeps running in background that uses repos and that's why there is problem that they can't be deleted for next test... I spend 5 hours on weekend trying to pinpoint where but with no success :(

os.Exit(m.Run())
exitStatus := m.Run()
if err = os.RemoveAll(setting.RepoRootPath); err != nil {
fatalTestError("os.RemoveAll: %v\n", err)
Copy link
Member

Choose a reason for hiding this comment

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

why not just use assert.NoError(t, err)?

Copy link
Member Author

Choose a reason for hiding this comment

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

There is no t variable

Copy link
Member

Choose a reason for hiding this comment

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

yes, sorry, overlooked :)

}

os.Exit(m.Run())
exitStatus := m.Run()
if err = os.RemoveAll(setting.RepoRootPath); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

Please use removeAllWithRetry func

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@tboerger tboerger added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Feb 20, 2018
@tboerger tboerger added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Feb 20, 2018
@lunny lunny merged commit d27d720 into go-gitea:master Feb 21, 2018
}

os.Exit(m.Run())
exitStatus := m.Run()
if err = removeAllWithRetry(setting.RepoRootPath); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

These should be defered. Not done at the end

@go-gitea go-gitea locked and limited conversation to collaborators Nov 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants