Skip to content

Adding small test update for temp dir using t.TempDir#13293

Merged
jesusvazquez merged 2 commits intoprometheus:mainfrom
miledxz:update-temp-dir-unit-tests
Dec 28, 2023
Merged

Adding small test update for temp dir using t.TempDir#13293
jesusvazquez merged 2 commits intoprometheus:mainfrom
miledxz:update-temp-dir-unit-tests

Conversation

@miledxz
Copy link
Copy Markdown
Contributor

@miledxz miledxz commented Dec 15, 2023

This is a little fix update for this issue:
#9594

Use case. Why is this important?
Error handling is implicit.
Cleanup is implicit.

@miledxz
Copy link
Copy Markdown
Contributor Author

miledxz commented Dec 15, 2023

Im also pinging @beorn7 , for review if possible

require.NoError(t, err)
defer os.RemoveAll(dir)
dir := t.TempDir()
t.Cleanup(func() {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

t.TempDir() TempDir returns a temporary directory for the test to use. The directory is automatically removed by Cleanup when the test and all its subtests complete.

Suggested change
t.Cleanup(func() {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@roidelapluie thank you for the explanation, all make sense, I will update pr

Signed-off-by: Mile Druzijanic <miledruz@gmail.com>
Signed-off-by: Mile Druzijanic <zedsprogramms@gmail.com>
Signed-off-by: Mile Druzijanic <zedsprogramms@gmail.com>
@miledxz miledxz force-pushed the update-temp-dir-unit-tests branch from 1ffe445 to 1620867 Compare December 20, 2023 08:05
@miledxz miledxz requested a review from roidelapluie December 21, 2023 10:32
Copy link
Copy Markdown
Member

@jesusvazquez jesusvazquez left a comment

Choose a reason for hiding this comment

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

LGTM Thank you for your contribution

@jesusvazquez jesusvazquez merged commit 2ddb359 into prometheus:main Dec 28, 2023
})

tmpdir := t.TempDir()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

FYI this is a line consisting only of tabs, which fails current linting rules.

@bboreham
Copy link
Copy Markdown
Member

TestQueryConcurrency is now failing consistently on Windows, e.g. https://github.com/prometheus/prometheus/actions/runs/7364591505/job/20045110499?pr=13343

I think I will revert this change until we sort out what has gone wrong.

bboreham added a commit that referenced this pull request Dec 30, 2023
This reverts commit 2ddb359.

Various tests are failing in CI after this change; reverting to free up
other work.
bboreham added a commit that referenced this pull request Dec 30, 2023
This reverts commit 2ddb359.

Various tests are failing in CI after this change; reverting to free up
other work.

Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
bboreham added a commit that referenced this pull request Dec 30, 2023
Revert "Adding small test update for temp dir using t.TempDir (#13293)"
fbegyn pushed a commit to fbegyn/prometheus that referenced this pull request Jul 11, 2024
* Adding small test update for temp dir using t.TempDir

Signed-off-by: Mile Druzijanic <miledruz@gmail.com>
Signed-off-by: Mile Druzijanic <zedsprogramms@gmail.com>

* removing not required cleanup

Signed-off-by: Mile Druzijanic <zedsprogramms@gmail.com>

---------

Signed-off-by: Mile Druzijanic <miledruz@gmail.com>
Signed-off-by: Mile Druzijanic <zedsprogramms@gmail.com>
fbegyn pushed a commit to fbegyn/prometheus that referenced this pull request Jul 11, 2024
…heus#13293)"

This reverts commit 2ddb359.

Various tests are failing in CI after this change; reverting to free up
other work.

Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
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