-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
tests/tail
: Fix tests to reflect changes from the refactoring #3905
#3965
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
Conversation
tail
: Fix piped and redirected input for windows
b76af7f
to
7b354a2
Compare
tail
: Fix piped and redirected input for windowstail
: Fix piped and redirected input and other functionality
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like you forgot to include the changes in tail.rs
? I only see test_tail.rs
and random.rs
.
tests/by-util/test_tail.rs
Outdated
@@ -148,6 +150,7 @@ fn test_stdin_redirect_offset2() { | |||
.succeeded(); | |||
} | |||
|
|||
// TODO: Use a debug_assert() instead |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of what? Also debug_assert
is not very meaningful in tests. Tests are not included in regular binaries and should probably always fail early if something yas gone wrong, even when run with --release
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, seems my TODOs are only meant for me. This is a quick one about adding a debug_assert() in tail.rs() after the immediate exit because of -[nc]0 without -f
instead of trying to provoke an error like passing a missing file to tail. A debug_assert() is more precise in my eyes.
tests/by-util/test_tail.rs
Outdated
#[test] | ||
#[cfg(all(unix, not(target_os = "freebsd")))] | ||
fn test_nc_0_wo_follow2() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because the test is platform specific in contrast to test_nc_0_wo_follow
and it doesn't more information. In my eyes the test_nc_0_wo_follow
test was sufficient. However, it could be more precise with the debug_assert(). If you like to, I can readd it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't follow your reasoning.
Because the test is platform specific in contrast to test_nc_0_wo_follow
This should not be a reason to remove a test.
and it doesn't more information.
But the two tests check different things.
tests/by-util/test_tail.rs
Outdated
not(target_os = "windows"), | ||
not(target_os = "android"), | ||
not(target_os = "freebsd") | ||
))] // FIXME: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a couple of these FIXME:
comments. I'd say either give an explanation or remove the colon :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, my FIXME parser doesn't colorize these without the colon. Maybe I can change that somewhere in the settings. I hoped the FIXMEs are seen as annotation for the not working platforms.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
However, I'll write a short explanation for the standalone FIXMEs :)
tests/by-util/test_tail.rs
Outdated
@@ -363,7 +340,6 @@ fn test_follow_stdin_name_retry() { | |||
} | |||
|
|||
#[test] | |||
#[cfg(target_os = "linux")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this test gonna work on all platforms eventually or can it only be fixed for some platforms?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably keep the cfg
then, ut was probably added for a reason.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
tests/by-util/test_tail.rs
Outdated
new_ucmd!() | ||
.args(&["-c", "1Y", "emptyfile.txt"]) | ||
.fails() | ||
.stderr_str() | ||
.starts_with("tail: invalid number of bytes: '1Y': Value too large for defined data type"); | ||
#[cfg(not(target_pointer_width = "128"))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feels like we should definitely keep these? CI can't cover every possible arch and OS we want to run the tests on
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
tests/common/random.rs
Outdated
@@ -310,5 +310,25 @@ mod tests { | |||
random_string.as_bytes().iter().filter(|p| **p == 0).count() | |||
); | |||
assert!(random_string.as_bytes().ends_with(&[0])); | |||
|
|||
// This test exists to exclude an error (timeout) occurred during system tests on windows |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does it do this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does so because this is the exact code from the test in which I used the random generator and the test timed out. But there's more code in the test, so to exclude the possibility that it has something to do with the random string generator, I added these lines from the test here and test them separately.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, ok, I'm not 100% if this is useful, but I think it's a vit better to at least add that explanation to the code here
I didn't change anything in |
@tertsdiepraam A little addition to my last comment. I'm not sure if my explanation in the header of this pr was a little bit short. This pr doesn't change any production code. I've already done this in the refactoring pr. I'm kind of summarizing in this pr, what was achieved in the refactoring pr #3905. |
I see. That makes sense, but indeed wasn't totally clear to me from the title and description. |
tail
: Fix piped and redirected input and other functionalitytests/tail
: Fix tests to reflect changes from the refactoring #3905
@tertsdiepraam I updated the title and description |
2e86269
to
c6a2d5d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I generally like this change. Enabling more tests is always good. I have two more small comments and please put the removed test back from the last review.
tests/by-util/test_tail.rs
Outdated
// TODO: Use a debug_assert() in tail.rs, which is more precise, to verify we're | ||
// exiting immediately instead of the approach below. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this TODO
c6a2d5d
to
8f80def
Compare
Thanks :) and thanks for the review.
Generally, I like more tests, too. But here, I also wanted to cement what we gained so far.
Concerning the TODO and tests, please let me propose an alternative solution, which improves these tests a little bit. Originally, I didn't want to alter production files in this pr, so I kept this TODO. However, I added an additional commit, so you can see, what I meant with the TODO. |
Please do not remove the two |
@tertsdiepraam Did you already have a look at the last commit? |
Sorry, I don't like the |
@tertsdiepraam No problem. |
8f80def
to
41226ba
Compare
@tertsdiepraam I took care of all your comments. The macos timeout looks like a ci problem. All other tests on macos have been running successfully... |
41226ba
to
6485f58
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
Please consider my suggestions.
Thanks for all the extensive testing on the various platforms.
tests/by-util/test_tail.rs
Outdated
@@ -1512,7 +1540,7 @@ fn test_retry8() { | |||
} | |||
|
|||
#[test] | |||
#[cfg(all(unix, not(any(target_os = "android", target_vendor = "apple"))))] // FIXME: make this work not just on Linux | |||
#[cfg(all(not(target_os = "windows"), not(target_os = "freebsd")))] // FIXME: for currently not working platforms |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test is problematic. It has been observed to sometimes fail on MinRustV and now macOS.
#3929
Until this is fixed I would not relax the cfg.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
won't fix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you aware that this comes across as quite rude? Why is this a won't fix? @jhscheer brings up a valid problem with your PR, so that needs to be fixed before we can merge this. I'm unresolving this conversation until it is actually resolved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a won't fix because this is actually valuable information about the intermittenly failing tests. Additionally, these intermittently failing tests are not part of this pr nor the refactoring on which this pr is based on. You may wish to disable the test until it is fixed, but I would suggest another pr for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But this PR enables the test on mac, which is not correct. So this PR should not introduce that change in the first place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The retry9 test is failing intermittently, but not because of the refactoring pr. It also does on macos but now you can notice this fact and maybe it helps figuring out the problem. The test usually passes and if not then because of #3929.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We try to keep intermittent failure to a minimum, because it affects everyone's CI for PRs. We can't accept PRs that knowingly introduce more intermittent failures.
but not because of the refactoring pr.
The refactoring PR has nothing to do with this. There is a test that fails (intermittently) and this PR enables it, which is a problem and that is why this PR has to just not do that.
It also does on macos but now you can notice this fact and maybe it helps figuring out the problem.
We now indeed know this and that is helpful, but that's not a valid reason that we should ignore the problem here. We're not asking you to fix anything, just to revert the change that you made for this specific test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not meant badly, I'm not sure this is going into the right direction, but if dsabling this test on macos is all you want, it's done.
// FIXME: windows: this test failed with timeout in the CI. Running this test in | ||
// a Windows VirtualBox image produces no errors. | ||
#[test] | ||
#[cfg(not(target_os = "windows"))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case a test runs locally but not in the CI, I would use is_ci()
, instead of disabling the test completely.
e.g.
if cfg!(windows) && is_ci() {
println!("TEST SKIPPED (<reason>)");
return;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
won't fix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please explain why "Won't fix"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I won't change it, because it's correct the way it is. It clearly indicates the implementation has a problem on windows. The comment just explains what I've found out and is a help for others. Sure it's failing in the ci and passing on my pc and my virtualbox but that doesn't mean there's something wrong with the implementation for windows, so it is switched off entirely. Windows pipes are different from unix pipes and fixing this in this pr is out of the scope of this pr. Additionally, if someone's running the test suite on windows but working on uutils in a different place he may probably run in this timeout.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jhscheer ok with you?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
// FIXME: windows: this test failed with timeout in the CI. Running this test in | ||
// a Windows VirtualBox image produces no errors. | ||
#[test] | ||
#[cfg(not(target_os = "windows"))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment about is_ci()
above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
won't fix
8a4416a
to
0897bbc
Compare
0897bbc
to
1725151
Compare
This is a follow up pr to #3905 (refactoring tail), in which the tests for tail are updated to reflect the current state of tail's implementation.
I removed all cfg attributes from the tests which limited the tests by vendor, os (ci 8594), then added cfg attributes again for the tests failing in the ci for a specific target os (ci 8604, ci 8605, ci 8606, ci 8607). This is a quick overview over the outcome and the main differences to before the refactoring:
Summary and curated diff from this branch to main
For completeness:
I needed to keep 2 piped input tests for windows switched off which are not working in the ci because the tests timed out. I couldn't reproduce locally why they are hanging and they ran successfully in a Windows 10 Virtualbox image.
Fixes #3881