user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH] t/search: show file modes as octal on failures
Date: Thu,  3 Oct 2019 07:38:17 +0000	[thread overview]
Message-ID: <20191003073817.13259-1-e@80x24.org> (raw)

This ought to make permissions errors on odd systems
easier to diagnose in the future.
---
 t/search.t | 44 +++++++++++++++++++++++---------------------
 1 file changed, 23 insertions(+), 21 deletions(-)

diff --git a/t/search.t b/t/search.t
index b1dbb301..830c668e 100644
--- a/t/search.t
+++ b/t/search.t
@@ -35,28 +35,30 @@ my $rw_commit = sub {
 	$rw->begin_txn_lazy;
 };
 
+sub oct_is ($$$) {
+	my ($got, $exp, $msg) = @_;
+	is(sprintf('0%03o', $got), sprintf('0%03o', $exp), $msg);
+}
+
 {
 	# git repository perms
-	is($ibx->_git_config_perm(), &PublicInbox::InboxWritable::PERM_GROUP,
-	   "undefined permission is group");
-	is(PublicInbox::InboxWritable::_umask_for(
-	     PublicInbox::InboxWritable->_git_config_perm('0644')),
-	   0022, "644 => umask(0022)");
-	is(PublicInbox::InboxWritable::_umask_for(
-	     PublicInbox::InboxWritable->_git_config_perm('0600')),
-	   0077, "600 => umask(0077)");
-	is(PublicInbox::InboxWritable::_umask_for(
-	     PublicInbox::InboxWritable->_git_config_perm('0640')),
-	   0027, "640 => umask(0027)");
-	is(PublicInbox::InboxWritable::_umask_for(
-	     PublicInbox::InboxWritable->_git_config_perm('group')),
-	   0007, 'group => umask(0007)');
-	is(PublicInbox::InboxWritable::_umask_for(
-	     PublicInbox::InboxWritable->_git_config_perm('everybody')),
-	   0002, 'everybody => umask(0002)');
-	is(PublicInbox::InboxWritable::_umask_for(
-	     PublicInbox::InboxWritable->_git_config_perm('umask')),
-	   umask, 'umask => existing umask');
+	oct_is($ibx->_git_config_perm(),
+		&PublicInbox::InboxWritable::PERM_GROUP,
+		'undefined permission is group');
+	my @t = (
+		[ '0644', 0022, '644 => umask(0022)' ],
+		[ '0600', 0077, '600 => umask(0077)' ],
+		[ '0640', 0027, '640 => umask(0027)' ],
+		[ 'group', 0007, 'group => umask(0007)' ],
+		[ 'everybody', 0002, 'everybody => umask(0002)' ],
+		[ 'umask', umask, 'umask => existing umask' ],
+	);
+	for (@t) {
+		my ($perm, $exp, $msg) = @$_;
+		my $got = PublicInbox::InboxWritable::_umask_for(
+			PublicInbox::InboxWritable->_git_config_perm($perm));
+		oct_is($got, $exp, $msg);
+	}
 }
 
 $ibx->with_umask(sub {
@@ -452,7 +454,7 @@ foreach my $f ("$git_dir/public-inbox/msgmap.sqlite3",
 		glob("$git_dir/public-inbox/xapian*/*")) {
 	my @st = stat($f);
 	my ($bn) = (split(m!/!, $f))[-1];
-	is($st[2] & $all_mask, -f _ ? 0660 : $dir_mask,
+	oct_is($st[2] & $all_mask, -f _ ? 0660 : $dir_mask,
 		"sharedRepository respected for $bn");
 }
 
-- 
EW


                 reply	other threads:[~2019-10-03  7:38 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191003073817.13259-1-e@80x24.org \
    --to=e@80x24.org \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).