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

tests: Improve reporting in case of FS errors #2216

Merged
merged 2 commits into from
Jan 23, 2025
Merged

Conversation

denik
Copy link
Contributor

@denik denik commented Jan 23, 2025

Changes

If there are unreadable files in a directory, raise an error but continue with further diagnostics, because the answer is in the script output.

Tests

Manually - I'm working on some tests that create unreadable files, the report is much better with this change.

If there are unreadable files in a directory, raise an error
but continue with futher diagnostics, because the answer is
in the script output.
var files []string
err := filepath.Walk(src, func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
t.Errorf("Error when listing %s: path=%s: %s", src, path, err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you include a comment on why neither needs to t.FailNow()?

The returned value will be incomplete and additional asserts will run, potentially masking this underlying issue.

Copy link
Contributor Author

@denik denik Jan 23, 2025

Choose a reason for hiding this comment

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

I tried :)

Title: If there are unreadable files in a directory, raise an error but continue with further diagnostics, because the answer is in the script output.

The output comparison is happening after this call which includes output.txt which includes errors printed by commands which include explanation why a given file cannot be read.

The returned value will be incomplete and additional asserts will run, potentially masking this underlying issue.

It is not masked, everything will be printed. We do not know which one is more relevant in advance. In my case latter was more relevant.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@denik denik enabled auto-merge January 23, 2025 11:17
@denik denik temporarily deployed to test-trigger-is January 23, 2025 11:19 — with GitHub Actions Inactive
@denik denik added this pull request to the merge queue Jan 23, 2025
Merged via the queue into main with commit 1f63aa0 Jan 23, 2025
9 checks passed
@denik denik deleted the denik/acceptance-list-dir branch January 23, 2025 11:53
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.

2 participants