From 9b920de937b18e59e106ee0a7a5bb313b9be0d0c Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Wed, 5 Feb 2020 23:14:00 -0700 Subject: skip some tests if we detect tmpfs device ID issues Signed-off-by: Sean Whitton --- t/21_annex-to-annex.t | 2 ++ t/22_annex-to-annex-dropunused.t | 3 +++ t/lib/t/Util.pm | 19 ++++++++++++++++++- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/t/21_annex-to-annex.t b/t/21_annex-to-annex.t index 2666b4b..9e84388 100755 --- a/t/21_annex-to-annex.t +++ b/t/21_annex-to-annex.t @@ -14,6 +14,8 @@ use Capture::Tiny qw(capture_merged); use File::Spec::Functions qw(catfile rel2abs); use File::chdir; +plan skip_all => "device ID issues" if device_id_issues; + # make sure that `make test` will always use the right version of the # script we seek to test # diff --git a/t/22_annex-to-annex-dropunused.t b/t/22_annex-to-annex-dropunused.t index fd0322a..c8bd47a 100755 --- a/t/22_annex-to-annex-dropunused.t +++ b/t/22_annex-to-annex-dropunused.t @@ -8,10 +8,13 @@ use lib 't/lib'; use Test::More; use File::Spec::Functions qw(rel2abs); use t::Setup; +use t::Util; use File::chdir; use File::Basename qw(dirname); use File::Copy qw(copy); +plan skip_all => "device ID issues" if device_id_issues; + # make sure that `make test` will always use the right version of the # script we seek to test my $a2a = "annex-to-annex"; diff --git a/t/lib/t/Util.pm b/t/lib/t/Util.pm index a69ac4c..bb8f59e 100644 --- a/t/lib/t/Util.pm +++ b/t/lib/t/Util.pm @@ -6,8 +6,10 @@ use warnings; use parent 'Exporter'; use File::Slurp; use File::Spec::Functions qw(rel2abs); +use File::chdir; +use File::Temp qw(tempdir); -our @EXPORT = qw( corrupt_annexed_file ); +our @EXPORT = qw( corrupt_annexed_file device_id_issues ); sub corrupt_annexed_file { my ($git, $file) = @_; @@ -20,4 +22,19 @@ sub corrupt_annexed_file { append_file $loc, "bazbaz\n"; } +# on a tmpfs as commonly used with sbuild, the device IDs for files +# and directories can be different, which will cause annex-to-annex to +# refuse to hardlink. we use this sub to skip some tests if we detect +# that. possibly annex-to-annex should only look at the device IDs of +# files (by creating a temporary file inside $dest and looking at the +# device ID of that) +sub device_id_issues { + local $CWD = tempdir CLEANUP => 1; + mkdir "foo"; + write_file "bar", "bar\n"; + my $foo_id = (stat "foo")[0]; + my $bar_id = (stat "bar")[0]; + return($foo_id != $bar_id); +} + 1; -- cgit v1.2.3