[pmg-devel] [PATCH log-tracker 1/3] update tests

Thomas Lamprecht t.lamprecht at proxmox.com
Fri Feb 26 14:08:56 CET 2021


On 26.02.21 13:52, Mira Limbeck wrote:
> On 2/26/21 10:22 AM, Mira Limbeck wrote:
>> On 2/25/21 11:56 AM, Thomas Lamprecht wrote:
>>> On 19.02.21 11:31, Mira Limbeck wrote:
>>>> As we only have month, day and time available but not the year, we have
>>>> to update the tests every year.
>>> I'm probably just missing context but why exactly is that the case?
>>>
>> The logs only contain month, day and time of the day which we parse. We do this based on the current date and timezone.
>>
>> So depending on the current date and the date in the logs, we either assume it to be in the past or in the future. This results in a different calculated CTIME then and the tests need to be updated accordingly.
> Correction, we always assume it to be in the past. But without the year info we assume it is no older than 1 year. This means when the test results we check against was created before that, the CTIME does not match anymore now.


Can't we just run the test under a fixed time? For common test harnesses which
run as specific commands one could use something like

faketime 2020-12-01 ./test-command

in the respective make target.

For cargo test based ones we could just add a wrapper helper around getting
the time and mock that in the #[cfg(not(test))] and #[cfg(test)], respectively.




More information about the pmg-devel mailing list