Protect xtests against the passage of time

There was a problem with the Vagrant tests where the year 2016 was hard-coded in as the modified date. This had to be done to make the --long tests use the correct date format, which varies depending on whether the timestamp is in the current year.

Unfortunately, time progresses [citation needed], and what was once 2016 is now 2017, so the date format changed and the tests broke.

Because the Vagrantfile is just a Ruby script, we can look up the current year at runtime and use that instead. There’s also a check added to the test runner that makes sure none of the files are more than 365 days old, because if any are, then it’s time to update the timestamps (or it’s the last day of a leap year)
This commit is contained in:
Benjamin Sago 2017-04-28 19:26:57 +01:00
parent 2ba4e99251
commit b885b34aa6
2 changed files with 12 additions and 1 deletions

8
Vagrantfile vendored
View File

@ -38,9 +38,15 @@ Vagrant.configure("2") do |config|
%[id -u #{longuser} &>/dev/null || useradd #{longuser}]
test_dir = "/home/vagrant/testcases"
# Because the timestamps are formatted differently depending on whether
# theyre in the current year or not (see `details.rs`), we have to make
# sure that the files are created in the current year, so they get shown
# in the format we expect.
current_year = Date.today.year
some_date = "#{current_year}01011234.56" # 1st January, 12:34:56
invalid_uid = 666
invalid_gid = 616
some_date = "201601011234.56" # 1st January 2016, 12:34:56
# Delete old testcases if they exist already.
# This needs root because the generator does some sudo-ing.

View File

@ -12,6 +12,11 @@ testcases=~/testcases
results=/vagrant/xtests
# Check that no files were created more than a year ago.
# Files not from the current year use a different date format, meaning
# that tests will fail until the VM gets re-provisioned.
sudo find $testcases -mtime +365 -printf "File %p has not been modified since %TY! Consider re-provisioning; tests will probably fail.\n"
# Long view tests
$exa $testcases/files -l | diff -q - $results/files_l || exit 1
$exa $testcases/files -lh | diff -q - $results/files_lh || exit 1