Przeglądaj źródła

Refactor temporary test cases path to a tmpdir variable

This allows to change it in a single place.
Guillem Jover 16 lat temu
rodzic
commit
bc498b8ad1

+ 4 - 2
scripts/Makefile.am

@@ -132,6 +132,8 @@ uninstall-local:
 
 TEST_VERBOSE= 0
 
+test_tmpdir = t.tmp
+
 test_cases = \
 	t/000_pod.t \
 	t/100_Dpkg_Version.t \
@@ -175,10 +177,10 @@ test_data = \
 	t/750_Dpkg_Substvars/substvars1
 
 clean-local:
-	rm -fr t.tmp
+	rm -fr $(test_tmpdir)
 
 check: $(test_data) $(test_cases)
-	$(mkdir_p) t.tmp
+	$(mkdir_p) $(test_tmpdir)
 	PATH="$(top_builddir)/src:$(top_builddir)/scripts:$(PATH)" \
 	  srcdir=$(srcdir) DPKG_DATADIR=$(srcdir)/.. \
 	  PERL5LIB=$(srcdir) PERL_DL_NONLAZY=1 \

+ 31 - 29
scripts/t/500_Dpkg_Path.t

@@ -22,35 +22,37 @@ use_ok('Dpkg::Path', 'canonpath', 'resolve_symlink',
        'check_files_are_the_same', 'get_pkg_root_dir',
        'guess_pkg_root_dir', 'relative_to_pkg_root');
 
-mkdir "t.tmp/a";
-mkdir "t.tmp/a/b";
-mkdir "t.tmp/a/b/c";
-mkdir "t.tmp/a/DEBIAN";
-mkdir "t.tmp/debian";
-mkdir "t.tmp/debian/a";
-mkdir "t.tmp/debian/a/b";
-mkdir "t.tmp/debian/a/b/c";
-symlink "a/b/c", "t.tmp/cbis";
-symlink "/this/does/not/exist", "t.tmp/tmp";
-symlink ".", "t.tmp/here";
-
-is(canonpath("t.tmp/./a///b/c"), "t.tmp/a/b/c", "canonpath basic test");
-is(canonpath("t.tmp/a/b/../../a/b/c"), "t.tmp/a/b/c", "canonpath and ..");
-is(canonpath("t.tmp/a/b/c/../../"), "t.tmp/a", "canonpath .. at end");
-is(canonpath("t.tmp/cbis/../"), "t.tmp/cbis/..", "canonpath .. after symlink");
-
-is(resolve_symlink("t.tmp/here/cbis"), "t.tmp/here/a/b/c", "resolve_symlink");
-is(resolve_symlink("t.tmp/tmp"), "/this/does/not/exist", "resolve_symlink absolute");
-is(resolve_symlink("t.tmp/here"), "t.tmp", "resolve_symlink .");
-
-ok(!check_files_are_the_same("t.tmp/here", "t.tmp"), "Symlink is not the same!");
-ok(check_files_are_the_same("t.tmp/here/a", "t.tmp/a"), "Same directory");
-
-is(get_pkg_root_dir("t.tmp/a/b/c"), "t.tmp/a", "get_pkg_root_dir");
-is(guess_pkg_root_dir("t.tmp/a/b/c"), "t.tmp/a", "guess_pkg_root_dir");
-is(relative_to_pkg_root("t.tmp/a/b/c"), "b/c", "relative_to_pkg_root");
-
-chdir("t.tmp");
+my $tmpdir = 't.tmp';
+
+mkdir "$tmpdir/a";
+mkdir "$tmpdir/a/b";
+mkdir "$tmpdir/a/b/c";
+mkdir "$tmpdir/a/DEBIAN";
+mkdir "$tmpdir/debian";
+mkdir "$tmpdir/debian/a";
+mkdir "$tmpdir/debian/a/b";
+mkdir "$tmpdir/debian/a/b/c";
+symlink "a/b/c", "$tmpdir/cbis";
+symlink "/this/does/not/exist", "$tmpdir/tmp";
+symlink ".", "$tmpdir/here";
+
+is(canonpath("$tmpdir/./a///b/c"), "$tmpdir/a/b/c", "canonpath basic test");
+is(canonpath("$tmpdir/a/b/../../a/b/c"), "$tmpdir/a/b/c", "canonpath and ..");
+is(canonpath("$tmpdir/a/b/c/../../"), "$tmpdir/a", "canonpath .. at end");
+is(canonpath("$tmpdir/cbis/../"), "$tmpdir/cbis/..", "canonpath .. after symlink");
+
+is(resolve_symlink("$tmpdir/here/cbis"), "$tmpdir/here/a/b/c", "resolve_symlink");
+is(resolve_symlink("$tmpdir/tmp"), "/this/does/not/exist", "resolve_symlink absolute");
+is(resolve_symlink("$tmpdir/here"), $tmpdir, "resolve_symlink .");
+
+ok(!check_files_are_the_same("$tmpdir/here", $tmpdir), "Symlink is not the same!");
+ok(check_files_are_the_same("$tmpdir/here/a", "$tmpdir/a"), "Same directory");
+
+is(get_pkg_root_dir("$tmpdir/a/b/c"), "$tmpdir/a", "get_pkg_root_dir");
+is(guess_pkg_root_dir("$tmpdir/a/b/c"), "$tmpdir/a", "guess_pkg_root_dir");
+is(relative_to_pkg_root("$tmpdir/a/b/c"), "b/c", "relative_to_pkg_root");
+
+chdir($tmpdir);
 
 ok(!defined(get_pkg_root_dir("debian/a/b/c")), "get_pkg_root_dir undef");
 ok(!defined(relative_to_pkg_root("debian/a/b/c")), "relative_to_pkg_root");

+ 5 - 4
scripts/t/900_update_alternatives.t

@@ -21,9 +21,10 @@ use strict;
 use warnings;
 
 my $srcdir = $ENV{srcdir} || '.';
-my $admindir = File::Spec->rel2abs("t.tmp/ua/admindir"),
-my $altdir = File::Spec->rel2abs("t.tmp/ua/alternatives");
-my $bindir = File::Spec->rel2abs("t.tmp/ua/bin");
+my $tmpdir = 't.tmp';
+my $admindir = File::Spec->rel2abs("$tmpdir/admindir"),
+my $altdir = File::Spec->rel2abs("$tmpdir/alternatives");
+my $bindir = File::Spec->rel2abs("$tmpdir/bin");
 # XXX: switch to version without .pl
 my @ua = ("$srcdir/update-alternatives.pl", "--log", "/dev/null",
           "--quiet", "--admindir", "$admindir", "--altdir", "$altdir");
@@ -69,7 +70,7 @@ plan tests => (4 * ($nb_slaves + 1) + 2) * 24 # number of check_choices
 		+ 63;			      # rest
 
 sub cleanup {
-    system("rm -rf t.tmp/ua && mkdir -p $admindir && mkdir -p $altdir");
+    system("rm -rf $tmpdir && mkdir -p $admindir && mkdir -p $altdir");
     system("mkdir -p $bindir/more");
 }