-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Replace deprecated shell commands #4907
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
|
The |
|
I'm looking into it but can't seem to get the syntax right for the tests to pass. |
|
I'm not sure if the error is related to the tests syntax. In every case, the returned value was different than the expected one. Example (line 677):
But I have no idea why this is happening. |
mock_command('uname', {'-m': ('armv8a', '0')}, host)
# mock `command -v sh` to return `/bin/sh`
mock_command('command', {'-v sh': ('/bin/sh', '0')}, host) |
Because the code to mock what platform is being reported has changed but the test haven't. So every test now checks the actual |
|
I thought both codes would report the same output. |
They usually do, but in the test environment the output needs to be faked/mocked for system/architecture dependant tests. And EDIT: I guess both return |
|
You basically need to change 8 lines of code (+8 lines of comments): pi-hole/test/test_any_automated_install.py Lines 622 to 623 in 997a771
pi-hole/test/test_any_automated_install.py Lines 650 to 651 in 997a771
pi-hole/test/test_any_automated_install.py Lines 678 to 679 in 997a771
pi-hole/test/test_any_automated_install.py Lines 707 to 708 in 997a771
pi-hole/test/test_any_automated_install.py Lines 737 to 738 in 997a771
pi-hole/test/test_any_automated_install.py Lines 766 to 767 in 997a771
pi-hole/test/test_any_automated_install.py Lines 792 to 793 in 997a771
pi-hole/test/test_any_automated_install.py Lines 816 to 817 in 997a771
Replace the P.S. You will also need to rebase your code on the latest |
Signed-off-by: a1346054 <[email protected]>
`command -v` is the standardized version of `which` and doesn't require any extra packages Signed-off-by: a1346054 <[email protected]>
Signed-off-by: a1346054 <[email protected]>
|
Strange, tests fail with the same error. Mocking multiple arguments via |
That doesn't seem to be the problem according to the failure logs in the tests. It expects return of a different architecture than the one that is actually being returned. I need to look into where it actually performs that check. |
|
Since the Since the two tests on Debian succeed, I guess |
|
Interestingly, it's passing on Debian OS.... |
|
Here it's the other way round, Debian fails, all others succeed: https://github.com/a1346054/pi-hole/commit/c650e42 => https://github.com/MichaIng/pi-hole/actions/runs/3229542602/jobs/5286970802 However, this proves that the mock does not work, as mentioned above, probably because |
|
Jep, it is like that, if I interpret the test helper correctly: https://github.com/pi-hole/pi-hole/blob/0df38cd/test/conftest.py#L55 Easiest solution is probably to mock both, EDIT: The container is a mutation of the official Debian container, which indeed ships without the symlinks. I opened an issue to suggest just this: debuerreotype/docker-debian-artifacts#180 |
Since "command" is a shell internal, it cannot be mocked, done via /usr/local/bin override. Since Debian containers ship without /bin => /usr/bin symlink, while all other containers do, the "ldd" mock needs to be applied for both paths, then. Signed-off-by: MichaIng <[email protected]>
|
PR up to fix tests in this PR: https://github.com/a1346054/pi-hole/pull/1 |
|
Pretty clever! |
|
You need to un-draft to trigger the tests |
Increased compatibility with systems and removal of deprecation warnings.
Removes deprecated and nonstandard shell utilities
egrepandwhichwith standardized versionsgrep -Eandcommand -vNone.
By submitting this pull request, I confirm the following:
git rebase)