[debhelper-devel] [Git][debian/debhelper][master] 2 commits: t/dh_usrlocal/01-basic.t: Refactor test

Niels Thykier gitlab at salsa.debian.org
Sat Apr 7 11:03:35 UTC 2018


Niels Thykier pushed to branch master at Debian / debhelper


Commits:
3d8fea37 by Niels Thykier at 2018-04-07T10:56:03+00:00
t/dh_usrlocal/01-basic.t: Refactor test

Signed-off-by: Niels Thykier <niels at thykier.net>

- - - - -
c7a3a4bd by Niels Thykier at 2018-04-07T11:01:38+00:00
t/dh_usrlocal: Add tests from Nicolas Boulenguez

Signed-off-by: Niels Thykier <niels at thykier.net>

- - - - -


1 changed file:

- t/dh_usrlocal/01-basic.t


Changes:

=====================================
t/dh_usrlocal/01-basic.t
=====================================
--- a/t/dh_usrlocal/01-basic.t
+++ b/t/dh_usrlocal/01-basic.t
@@ -32,8 +32,9 @@ sub extract_generated_lines {
 	return @lines;
 }
 
-each_compat_subtest {
 
+sub perform_test {
+	my ($install_dirs, $expected_dirs_postinst, $expected_dirs_prerm) = @_;
 	my (@postinst, @prerm);
 	my @scripts = qw(
         debian/debhelper.postinst.debhelper
@@ -42,52 +43,115 @@ each_compat_subtest {
 
 	rm_files(@scripts);
 	remove_tree('debian/debhelper');
-	install_dir('debian/debhelper/usr/local/foo');
-	install_dir('debian/debhelper/usr/local/bar');
+	install_dir(map { "debian/debhelper/$_" } @{$install_dirs});
 
 	ok(run_dh_tool('dh_usrlocal'));
+
 	@postinst = extract_generated_lines("debian/debhelper.postinst.debhelper");
 	@prerm = extract_generated_lines("debian/debhelper.prerm.debhelper");
 
-	is_deeply(\@postinst, [
-				  '/usr/local/bar 02775 root staff',
-				  '/usr/local/foo 02775 root staff',
-			  ], "Correct dir creation")
-		or do { diag("postinst: $_") for @postinst; };
-	is_deeply(\@prerm, [], "No removal of top level dirs #894549")
-		or do { diag("prerm: $_") for @prerm; };
-	
-	remove_tree('debian/debhelper');
-	rm_files(@scripts);
-	install_dir('debian/debhelper/usr/local/foo/dir/somewhere');
-	install_dir('debian/debhelper/usr/local/bar/another-dir/elsewhere');
-	install_dir('debian/debhelper/usr/local/baz/foo+bar/thing');
+	is_deeply(\@postinst,
+			  [map { "$_ 02775 root staff" } @{$expected_dirs_postinst}],
+			  "Correct postinst"
+		) or do { diag("postinst: $_") for @postinst; };
+	is_deeply(\@prerm,
+			  $expected_dirs_prerm,
+			  "Correct prerm"
+		) or do { diag("prerm: $_") for @prerm; };
+}
 
-	ok(run_dh_tool('dh_usrlocal'));
+each_compat_subtest {
 
-	@postinst = extract_generated_lines("debian/debhelper.postinst.debhelper");
-	@prerm = extract_generated_lines("debian/debhelper.prerm.debhelper");
+	perform_test(
+		['/usr/local/bar', '/usr/local/foo'],
+		['/usr/local/bar', '/usr/local/foo'],
+		[]
+	);
+
+	perform_test(
+		[
+		 '/usr/local/foo/bar',
+		 '/usr/local/foo/baz',
+		],
+		[
+		 '/usr/local/foo',
+		 '/usr/local/foo/bar',
+		 '/usr/local/foo/baz',
+		],
+		[
+		 '/usr/local/foo/bar',
+		 '/usr/local/foo/baz',
+		]
+	);
+
+	perform_test(
+		[qw(
+		 /usr/local/a/a/a
+		 /usr/local/a/a/b
+		 /usr/local/a/b/a
+		 /usr/local/a/b/b
+		 /usr/local/b/a/a
+		 /usr/local/b/a/b
+		 /usr/local/b/b/a
+		 /usr/local/b/b/b
+		)],
+		[qw(
+		 /usr/local/a
+		 /usr/local/a/a
+		 /usr/local/a/a/a
+		 /usr/local/a/a/b
+		 /usr/local/a/b
+		 /usr/local/a/b/a
+		 /usr/local/a/b/b
+		 /usr/local/b
+		 /usr/local/b/a
+		 /usr/local/b/a/a
+		 /usr/local/b/a/b
+		 /usr/local/b/b
+		 /usr/local/b/b/a
+		 /usr/local/b/b/b
+		 )],
+		[qw(
+		 /usr/local/a/a/a
+		 /usr/local/a/a/b
+		 /usr/local/a/a
+		 /usr/local/a/b/a
+		 /usr/local/a/b/b
+		 /usr/local/a/b
+		 /usr/local/b/a/a
+		 /usr/local/b/a/b
+		 /usr/local/b/a
+		 /usr/local/b/b/a
+		 /usr/local/b/b/b
+		 /usr/local/b/b
+		 )]
+	);
 
-	is_deeply(\@postinst, [
-				  '/usr/local/bar 02775 root staff',
-				  '/usr/local/bar/another-dir 02775 root staff',
-				  '/usr/local/bar/another-dir/elsewhere 02775 root staff',
-				  '/usr/local/baz 02775 root staff',
-				  '/usr/local/baz/foo+bar 02775 root staff',
-				  '/usr/local/baz/foo+bar/thing 02775 root staff',
-				  '/usr/local/foo 02775 root staff',
-				  '/usr/local/foo/dir 02775 root staff',
-				  '/usr/local/foo/dir/somewhere 02775 root staff',
-			  ], "Correct dir creation")
-		or do { diag("postinst: $_") for @postinst; };
-	is_deeply(\@prerm, [
-				  '/usr/local/bar/another-dir/elsewhere',
-				  '/usr/local/bar/another-dir',
-				  '/usr/local/baz/foo+bar/thing',
-				  '/usr/local/baz/foo+bar',
-				  '/usr/local/foo/dir/somewhere',
-				  '/usr/local/foo/dir',
-			  ], "Correct dir removal")
-		or do { diag("prerm: $_") for @prerm; };
+	perform_test(
+		[
+		 '/usr/local/foo/dir/somewhere',
+		 '/usr/local/bar/another-dir/elsewhere',
+		 '/usr/local/baz/foo+bar/thing',
+		],
+		[
+		 '/usr/local/bar',
+		 '/usr/local/bar/another-dir',
+		 '/usr/local/bar/another-dir/elsewhere',
+		 '/usr/local/baz',
+		 '/usr/local/baz/foo+bar',
+		 '/usr/local/baz/foo+bar/thing',
+		 '/usr/local/foo',
+		 '/usr/local/foo/dir',
+		 '/usr/local/foo/dir/somewhere',
+		],
+		[
+		 '/usr/local/bar/another-dir/elsewhere',
+		 '/usr/local/bar/another-dir',
+		 '/usr/local/baz/foo+bar/thing',
+		 '/usr/local/baz/foo+bar',
+		 '/usr/local/foo/dir/somewhere',
+		 '/usr/local/foo/dir',
+		]
+	);
 };
 



View it on GitLab: https://salsa.debian.org/debian/debhelper/compare/1db0bd881f3329198415a08af61d01b0b8ba92ed...c7a3a4bd757a40d3834c000af2917a381eed9c9d

---
View it on GitLab: https://salsa.debian.org/debian/debhelper/compare/1db0bd881f3329198415a08af61d01b0b8ba92ed...c7a3a4bd757a40d3834c000af2917a381eed9c9d
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/debhelper-devel/attachments/20180407/a3e454b9/attachment-0001.html>


More information about the debhelper-devel mailing list