-
-
Notifications
You must be signed in to change notification settings - Fork 313
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
from_path_no_follow
test runs touch
with nonportable date format
#1491
Comments
For each edge-of-range `touch`, if at first it fails, try it rounded to the nearest *more extreme* value in seconds, which some implementations will accept and clip it at or near the most extreme value in the range that it was going for. See GitoxideLabs#1491.
Thanks for the incredibly detailed collection. Having merged this PR first probably allows me to give a brief summary of how I thought we could act in the face of The PR fixes the issue by essentially falling back to a portable date format that still satisfies the test. In theory, there is no need for the nanosecond version in the first place, but I though it was useful to leave it as a warning for the future. Setting mtimes in Rust might be more portable, and should probably be preferred, especially if sub-second precision is desirable. Lastly, tests should probably not assume subsecond precision and be able to deal with filesystems that cannot support it (even if this isn't a matter discussed in this issue). |
Is this to say that there is no need to attempt to test the very edge of the range even when it is possible to do so, but just within a second of it? I'll look into setting mtimes in Rust, which is already being done for some other tests: As I noted in #1496:
To the best of my knowledge, the time zone is the only way I think more substantial changes than those in #1496, including changing to setting the timestamp in Rust, should probably be done in a way that clearly accounts for issues of time zone and, if applicable, other locale issues. If time zone is the only way locale-related information impacts this, then I am not sure If sub-second precision doesn't have to be attempted, then I can either not bother with it when writing Rust code to set the timestamp, or if for some reason this shouldn't be done in Rust, I can remove the non-portable commands. This could be done at the same time as accounting for the time zone, if applicable. I wonder if the issue of whether the system clock itself is set to local time or to UTC is at all relevant to how the meaning of timestamps in the filesystem is interpreted. (When running a Unix-like operating system it is traditionally set to UTC, but it is sometimes set to local time instead, such as to solve clock skew problems when dual-booting with Windows, which defaults to assuming the system clock is set to local time.) |
Indeed, I totally admit though that I am a bit outside my comfort zone here as I don't remember what the tests truly need - index tests probably rely on sub-second precision sometimes to test for edge-cases in dirty-detection, and there is probably much I am missing or have forgotten. It seems you have a plan on the improvements to make, and I encourage you to go ahead with them choosing whichever means of setting mtimes that seem most appropriate. Sorry for being so vague here, I hope that when seeing a PR it will all come together for me. |
For each edge-of-range `touch`, if at first it fails, try it rounded to the nearest *more extreme* value in seconds, which some implementations will accept and clip it at or near the most extreme value in the range that it was going for. See GitoxideLabs#1491.
Current behavior 😯
The
from_path_no_follow
test calls thefile_metadata.sh
fixture that usestouch -d
with a date format that not alltouch
implementations support:https://github.com/Byron/gitoxide/blob/29898e3010bd3332418c683f2ac96aff5c8e72fa/gix-index/tests/fixtures/file_metadata.sh#L4-L5
Given the ext4-related goal, this may only be significant on systems where the filesystem is usually ext4, i.e., Linux-based systems. However, because not all Linux-based systems with a
touch
command have the GNU coreutils implementation, this is nonetheless significant.With BusyBox on Alpine Linux
On Alpine Linux, on which
touch
is provided by BusyBox, all tests except one are able to pass so long asbash
is installed (apk add bash
). This is as briefly noted in #1486 (comment). The one failing test is:The details of the failure are:
That is on Alpine Linux 3.17. Output of the whole test run is in this gist.
Manual confirmation on Alpine Linux
Running the command manually on that system produces the same
invalid date
error:Manual confirmation with BusyBox on a GNU/Linux system
The effect can be observed, with the same error message, on a GNU/Linux system where
touch
is provided by GNU coreutils and supports the syntax, if BusyBox is installed, by trying the command manually withbusybox
. This is from an Ubuntu 22.04 LTS system:The last command shows that the problem is not related to the date being out of range: even when a date in 2006 is used, the same
invalid date
error occurs. The reason I checked that was...Note that these systems are both called
Glub
because they are WSL distributions installed on the same machine, but they are separate distributions with separate filesystems (thetmp
directories are separate). I did verify withmount
that the filesystems are ext4, and I did also verify on a "bare metal" system that the effect also occurs.With GNU coreutils on a 32-bit Ubuntu 18.04.6 LTS ESM system
Some GNU/Linux systems with GNU coreutils also cannot run this command, and I am not sure why. A cursory examination of the GNU coreutils commit history does not seem to reveal the reason, but that is far from sufficient to rule out the possibility that older versions of GNU coreutils don't support the syntax. My suspicion, however, is that the system being 32-bit is a contributing factor, because on this system with GNU coreutils
touch
, a date in the same format is accepted when it is in 2006:This is on a 32-bit Ubuntu 18.04 LTS system with extended security maintenance enabled (so this system is still supported, in the sense that it is not yet end-of-life, even though it has reached the end of standard support). One should expect a number of such systems to be in continued use because, while old, this is the most recent version of Ubuntu that has both (a) support from Canonical (though doing so requires enabling Ubuntu Pro which is only free-of-charge under specific limited conditions), and (b) a 32-bit x86 release.
Although
gitoxide
builds and seems to work fine on this system, the machine is somewhat slow, and I have not recently attempted to run tests from the test suite on it or other 32-bit x86 systems.A red herring
This may superficially appear connected to #1488 because that is recent and they both concern dates, but it is completely unrelated. The affected code and (as far as I can tell) behavior are independent. I have also verified that the problem occurs both before and after that change.
Expected behavior 🤔
The test attempts to create a file with the latest date representable in the ext4 filesystem, and thus appears intended to be able to succeed on any Linux-based system with the expected command-line tools, so long as the filesystem is ext4. So I think the expected behavior is to successfully create the file even if the
touch
command does not support all the formats supported by GNU coreutilstouch
.The fixture currently always runs, because it is explicitly
.gitignore
d. But this appears intentional.I'm not sure what the best way to fix this is, but I have a few ideas:
Two tests set timestamps with
filetime::set_file_mtime
. Perhaps that or another timestamp-related function could be used instead of calling the externaltouch
command.I'm not sure how portable this is, but specifying a later date in a recognized format works and sets the timestamp to the latest possible date and time even though that is earlier than what was specified:
The above shows the command on Alpine Linux 3.17. The nanoseconds show as all zeros when this is done, but that also happens both with GNU coreutils
touch
and with BusyBoxtouch
. If it is intended that the nanoseconds show a higher value, then there may be a separate bug related to that as well, which may or may not be feasible to fix with the same change that fixes this.In the 32-bit Ubuntu 18.04 system I tested on, the above technique did not work and gave the same error, suggesting that the error is really due to range rather than the format, on that system. Otherwise this seems to work both on GNU/Linux systems and on Alpine Linux. I'm not sure about other systems.
Edit: I've opened #1496 to propose a variation on this, where it tries the current approach first and, if that fails, tries again with the more portable date syntax specifying a date just outside the range.
If the date just needs to be far in the future, and we know how far it needs to be in order to effectively exercise the test--perhaps just after 2026--then a simpler, portable
touch
whose effect is intuitive could be used. (This might still fail on systems that don't support late enough dates, but it should overcome any format-related problems.)Git behavior
The issue is in a test fixture in gitoxide's test suite. There may be something similar in Git's test suite, but I am not aware of it. I could research that if it turns out to be valuable. A cursory search of the repository does not show tests in which
touch -d
commands are run.Steps to reproduce 🕹
Steps other than setting up software on the Alpine Linux 3.17 test system are given above.
Using
apk
, I installedbuild-base
to get common development tools including a C compiler and linker, as well as the usual additional tools required for buildinggitoxide
in its defaultmax
feature set, such aspkgconf
andcmake
. Like FreeBSD, Alpine Linux does not ship withbash
, so that must be installed too, since the test suite requires it.As shown in the above-linked gist, this is in the default
max
configuration (I did not pass any feature-related flags tocargo nextest
). Alpine Linux uses musl rather than glibc, and when installingrustup
, it automatically selects the correct musl-based toolchain. But to getgitoxide
to build, it was necessary to overcome a problem of build failures with musl and OpenSSL that, as noted in #1486 (comment), I believe are the same as those references in therelease.yml
workflow:https://github.com/Byron/gitoxide/blob/29898e3010bd3332418c683f2ac96aff5c8e72fa/.github/workflows/release.yml#L113-L115
https://github.com/Byron/gitoxide/blob/29898e3010bd3332418c683f2ac96aff5c8e72fa/.github/workflows/release.yml#L148-L150
Also as noted in #1486 (comment), the fix was to install
libressl-dev
--which brings inlibressl3.6-libcrypto
,libressl3.6-libssl
, andlibressl3.6-libtls
as dependencies--rather thanopenssl
andopenssl-dev
. This doesn't seem to actually be working (#1493), and originally (including in the original draft of this issue) I had thought the problem was specific to using the binary on other systems but actually it happens on the system where it is built. However, that shouldn't be a problem for this issue or the procedure for reproducing it, because the problem here is not related to that, is in a shell script rather than binary code, and is not specific to particular build configurations.The text was updated successfully, but these errors were encountered: