]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
devel/try-lei: for interactive testing + debugging
authorEric Wong <e@80x24.org>
Mon, 25 Nov 2024 22:27:48 +0000 (22:27 +0000)
committerEric Wong <e@80x24.org>
Wed, 27 Nov 2024 00:40:20 +0000 (00:40 +0000)
This script allows creating a clean lei instance for interactive
testing without modifying a user's current lei $HOME||$XDG_*
directories.  I used this to debug and test fixes leading to
99fc3d76 (v2writable: done: force synchronous awaitpid, 2024-11-19) and
807abf67 (lei/store: auto-commit for long-running imports, 2024-11-15)
fixes for long-running `lei import' runs.

MANIFEST
devel/try-lei [new file with mode: 0755]

index 6b759487fbb8032554dc7c236c589687a7952e47..1305ed8ac1715114b33fcbf090c7323bb062a80b 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -123,6 +123,7 @@ contrib/selinux/el7/publicinbox.te
 devel/README
 devel/longest-tests
 devel/sysdefs-list
+devel/try-lei
 examples/README
 examples/README.unsubscribe
 examples/cgit-commit-filter.lua
diff --git a/devel/try-lei b/devel/try-lei
new file mode 100755 (executable)
index 0000000..0a055d0
--- /dev/null
@@ -0,0 +1,28 @@
+# Copyright all contributors <meta@public-inbox.org>
+# License: AGPL-3.0+ <http://www.gnu.org/licenses/agpl-3.0.txt>
+# For interactive testing + debugging of lei with a clean $HOME:
+# Usage: ./devel/try-lei
+eval 'exec perl -w -S $0 ${1+"$@"}' # no shebang
+if 0; # running under some shell
+use autodie qw(mkdir symlink);
+my $cwd;
+BEGIN {
+       use Cwd qw(getcwd);
+       $cwd = getcwd;
+       die <<EOM unless -f 'lei.sh';
+must be run in top-level public-inbox worktree (cwd=$cwd)
+EOM
+       unshift @INC, "$cwd/lib";
+       $ENV{PERL5LIB} = join(':', @INC);
+}
+use PublicInbox::TestCommon;
+$ENV{TEST_RUN_MODE} = '0'; # no fork optimization
+test_lei(sub {
+       diag "spawning shell, HOME=$ENV{HOME}, will be deleted when done";
+       mkdir "$ENV{HOME}/bin";
+       diag "ln -s $cwd/lei.sh $ENV{HOME}/bin/lei";
+       symlink "$cwd/lei.sh", "$ENV{HOME}/bin/lei";
+       $ENV{PATH} = "$ENV{HOME}/bin:$ENV{PATH}";
+       is system($ENV{SHELL} // '/bin/sh'), 0, 'subshell ran successfully';
+});
+done_testing;