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

test: use T.TempDir to create temporary test directory #8295

Merged
merged 3 commits into from
Mar 17, 2022
Merged

test: use T.TempDir to create temporary test directory #8295

merged 3 commits into from
Mar 17, 2022

Conversation

Juneezee
Copy link
Contributor

@Juneezee Juneezee commented Mar 11, 2022

Related Issues

A testing enhancement.

Proposed Changes

Replaces ioutil.TempDir with T.TempDir function from the testing package to create temporary directory. The directory created by T.TempDir is automatically removed when the test and all its subtests complete.

Additional Info

Reference: https://pkg.go.dev/testing#T.TempDir

Checklist

Before you mark the PR ready for review, please make sure that:

  • All commits have a clear commit message.
  • The PR title is in the form of of <PR type>: <area>: <change being made>
    • example: fix: mempool: Introduce a cache for valid signatures
    • PR type: fix, feat, INTERFACE BREAKING CHANGE, CONSENSUS BREAKING, build, chore, ci, docs,perf, refactor, revert, style, test
    • area: api, chain, state, vm, data transfer, market, mempool, message, block production, multisig, networking, paychan, proving, sealing, wallet, deps
  • This PR has tests for new functionality or change in behaviour
  • If new user-facing features are introduced, clear usage guidelines and / or documentation updates should be included in https://lotus.filecoin.io or Discussion Tutorials.
  • CI is green

@Juneezee Juneezee requested a review from a team as a code owner March 11, 2022 06:35
@codecov
Copy link

codecov bot commented Mar 11, 2022

Codecov Report

Merging #8295 (c229842) into master (a431fdb) will decrease coverage by 0.02%.
The diff coverage is n/a.

❗ Current head c229842 differs from pull request most recent head 1c055fe. Consider uploading reports for the commit 1c055fe to get more accurate results

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #8295      +/-   ##
==========================================
- Coverage   40.34%   40.31%   -0.03%     
==========================================
  Files         679      679              
  Lines       73985    73958      -27     
==========================================
- Hits        29846    29819      -27     
- Misses      38900    38924      +24     
+ Partials     5239     5215      -24     
Impacted Files Coverage Δ
chain/actors/builtin/miner/diff.go 48.52% <0.00%> (-10.30%) ⬇️
extern/storage-sealing/states_proving.go 24.61% <0.00%> (-8.27%) ⬇️
storage/wdpost_sched.go 77.45% <0.00%> (-3.93%) ⬇️
extern/storage-sealing/input.go 51.47% <0.00%> (-3.87%) ⬇️
chain/events/events_height.go 68.90% <0.00%> (-2.53%) ⬇️
storage/miner_sealing.go 85.71% <0.00%> (-1.93%) ⬇️
extern/storage-sealing/fsm.go 55.40% <0.00%> (-1.65%) ⬇️
node/impl/storminer.go 21.48% <0.00%> (-1.43%) ⬇️
chain/store/store.go 63.66% <0.00%> (-1.34%) ⬇️
storage/wdpost_changehandler.go 97.64% <0.00%> (-0.95%) ⬇️
... and 36 more

Copy link
Contributor

@ZenGround0 ZenGround0 left a comment

Choose a reason for hiding this comment

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

Other than the test storage in the sector storage manager this LGTM. It looks like you've been keeping the ioutil temp dirs around in places where the current test does not delete the dir 👍. However I am less familiar with these other tests so it's hard to be sure.

Please go through and double check there are no more places where this change will remove test directories the current tests wouldn't and then this will be good to go.

extern/sector-storage/manager_test.go Outdated Show resolved Hide resolved
The directory created by `T.TempDir` is automatically removed when the
test and all its subtests complete.

Reference: https://pkg.go.dev/testing#T.TempDir
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
@Juneezee Juneezee requested a review from ZenGround0 March 14, 2022 16:24
Copy link
Contributor

@magik6k magik6k left a comment

Choose a reason for hiding this comment

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

Thanks!

node/repo/fsrepo_test.go Outdated Show resolved Hide resolved
lib/backupds/backupds_test.go Outdated Show resolved Hide resolved
@magik6k magik6k enabled auto-merge March 17, 2022 11:13
@magik6k magik6k disabled auto-merge March 17, 2022 11:30
@magik6k magik6k merged commit 73ab064 into filecoin-project:master Mar 17, 2022
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.

3 participants