about summary refs log tree commit homepage
path: root/lib/PublicInbox/TestCommon.pm
DateCommit message (Collapse)
2021-10-28test_common: clear XDG_CACHE_HOME before lei tests
We don't want to read a users' $XDG_CACHE_HOME/lei/all_locals_ever.git during tests. Reported-by: Thomas Weißschuh <thomas@t-8ch.de> Tested-by: Thomas Weißschuh <thomas@t-8ch.de> Link: https://public-inbox.org/meta/f239abac-4aee-4573-a0d6-e533c7a32662@t-8ch.de/
2021-10-27test_common: key test inboxes to init.defaultBranch
This lets users change their global init.defaultBranch config knob in ~/.gitconfig or similar without breaking tests. Reported-by: Thomas Weißschuh <thomas@t-8ch.de> Tested-by: Thomas Weißschuh <thomas@t-8ch.de>
2021-10-19test_common: lazy-require AutoReap
This might speed up non-daemon-using tests.
2021-10-15lei: TSTP affects all curl and related subprocesses
By relying more on pgroups for remaining remaining processes, this lets us pause all curl+tail subprocesses with a single kill(2) to avoid cluttering stderr. We won't bother pausing the pigz/gzip/bzip2/xz compressor process not cat-file processes, though, since those don't write to the terminal and they idle soon after the workers react to SIGSTOP. AutoReap is hoisted out from TestCommon.pm. CLONE_SKIP is gone since we won't be using Perl threads any time soon (they're discouraged by the maintainers of Perl).
2021-10-13test_common: hoist out tail_f sub
We'll be reusing this in more places. While we're at it, allow it to tail all run_script() users, including lei() in TestCommon.
2021-09-24clone|--mirror: fix and test against pre-manifest WWW
There may still be pre-manifest.js.gz versions of PublicInbox::WWW. running and serving v2 inboxes. Since $INBOX_URL/manifest.js.gz was not understood, it was assumed to be a Message-ID and 301-ed to "$INBOX_URL/manifest.js.gz/" with a trailing slash, so our 404 checks were invalid. Update our fallbacks to deal with 301 by catching JSON decoding errors to trigger HTML scraping. For HTML parsing, be sure to not be fooled by potential user-generated content and only scan the part after the last <hr>. We also need to avoid propagating $? from curl unnecessarily when we can continue safely. Finally, update v2mirror.t with tests to use PublicInbox::WWW from our "v1.1.0-pre1" tag to ensure these code paths get tested
2021-09-23test_common: reset umask on non-forking run_script
public-inbox-init sets umask for git <2.1.0, so our fork+exec replacement needs to restore the original umask of the "parent".
2021-09-22treewide: fix %SIG localization, harder
This fixes the occasional t/lei-sigpipe.t infinite loop under "make check-run". Link: http://nntp.perl.org/group/perl.perl5.porters/258784 <CAHhgV8hPbcmkzWizp6Vijw921M5BOXixj4+zTh3nRS9vRBYk8w@mail.gmail.com> Followup-to: b552bb9150775fe4 ("daemon+watch: fix localization of %SIG for non-signalfd users")
2021-09-21lei inspect: support NNTP URLs
No reason not to support them, since there's more public-inbox-nntpd instances than -imapd instances, currently.
2021-09-14test_common: remove non-hidden files, first
We want to remove any inotify-watched files before removing ~/.local/lei/store/ipc.lock, since sto_done_request was failing on attempts to lock a non-existent lei/store/ipc.lock file.
2021-09-13tests: add require_cmd, require curl when needed
t/v2mirror.t and t/lei-mirror.t are now skipped when curl is missing (instead of failing in appropriate places). A bunch of which() checks are updated to use require_cmd to avoid explicitly loading Spawn.
2021-09-12test_common: only print $@ for Gcf2 failure
Other missing dependencies are more straightforward, but Gcf2 requires a combination of libgit2-dev, pkg-config, Inline::C, and proper setup. This significantly reduces noise in tests with a minimal set of dependencies installed.
2021-09-12lei sucks: allow it to work without SQLite
And try to improve the message about Inline::C while we're at it, since Socket::Msghdr isn't widely-packaged, yet.
2021-09-12init: set a useful description
"Unnamed repository" for v1 inboxes was misleading, and having a non-existent description for v2 was equally annoying, so set a short description based on the primary address. We remove descriptions when setting up new test inboxes to preserve the behavior of the t/lei-mirror.t test case.
2021-09-10test_common: print diagnostic for missing dependencies
The "#" prefix should prevent it from being too alarming if a dependency is expected to be missing, but still useful if a dependency is misconfigured.
2021-05-26lei: require Socket::MsgHdr or Inline::C, drop oneshot
The cost of supporting separate code paths between oneshot and daemon isn't worth the trouble; especially if there are more users to support. The test suite time nearly doubles with oneshot, so that's hurting developer productivity. FD passing is currently required to work efficiently with remote HTTP(S) queries which return large messages, as seen in commit 708b182a57373172f5523f3dc297659d58e03b58 ("ipc: wq: handle >MAX_ARG_STRLEN && <EMSGSIZE case"). Additionally, upcoming support for IMAP IDLE and inotify-based monitoring of Maildirs cannot work properly without a background daemon.
2021-04-28tests: restore CWD with "lei -C" and run_script
This simplifies test_lei users in t/*.t
2021-04-24test_common: don't attempt to seek on pipes and terminals
This allows proper error reporting on daemon failure when using "check-run".
2021-04-24t/lei_to_mail: split "lei import" test $HOME directory
"lei import" behavior will may change w.r.t. keyword handling. Use separate $HOME between different test_lei to ensure isolation between the tests.
2021-04-22lei: XDG_RUNTIME_DIR=/dev/null disables daemon mode
We'll support this mode of operation for now to quiet down testing of oneshot mode where the daemon doesn't persist.
2021-04-20test_common: fix xbail for Perl 5.16
Our use of `ref' was triggering ambiguity in older versions of the Perl parser. Reported-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org> Link: https://public-inbox.org/meta/20210420174912.h6d2yv7zu5xr4yfc@nitro.local/
2021-04-16test_common: handle '-C' (chdir) spawn option properly
We use it in t/lei-q-save.t, and were inadvertently writing to the worktree. v2: fix -C $DIR with TEST_RUN_MODE=0
2021-04-03test_common: lei_ok: improve diagnostics
$? is useful, as is labeling lei_err since I'm easily-confused :x
2021-03-28treewide: shorten temporary filename
File::Temp only requires four 'X' characters (unlike mkstemp(3), which requires six). So only so only give it 4 to avoid an 80-column violation and maybe save metadata space on FSes.
2021-03-28test_common: require_mods bundles
This makes it easier to manage test dependencies on systems where optional stuff isn't installed. This fixes some lei tests which didn't check for Plack before starting -httpd, and ensures Parse::RecDescent is available for -imapd in case Mail::IMAPClient stops using it.
2021-03-25lei import: force store, improve test diagnostics
"lei import" should never be without a {sto}, and *_done should not be called multiple times, so ensure we can fail if it's missing. Update some existing tests to complain loudly by introducing a handy "xbail" function which wraps "explain" and BAIL_OUT. BAIL_OUT was painful to type and concatenating the result of "explain" doesn't work as I thought it would since "explain" always returns an array, and BAIL_OUT only accepts a single scalar arg (unlike "die").
2021-03-25tests: "check-run" uses persistent lei daemon
We'll use a lei-daemon if it's already running and TEST_LEI_DAEMON_PERSIST_DIR is set, but we can also start one and manage it from t/run.perl This drops "make check-run TEST_LEI_DAEMON_ONLY=1" time by ~10% for me.
2021-03-25test_common: TEST_LEI_ERR_LOUD does not hide path names
We hide paths by default to reduce noise, but we want noise with loud errors.
2021-03-25test_common: cleanup inbox objects after use
This stops us from leaking some more file handles across test cases.
2021-03-24test_common: check lei/errors.log
This will make it easier to diagnose some large internal rewrites.
2021-03-21lei: fix some warnings in tests
And then test the contents of $lei_err to ensure it doesn't happen again. We'll also make MboxLock emit nicer warnings without the line number, since the line number is irrelevant to the user fixing an mbox lock contention problem. Finally, we'll also allow showing loud warnings via TEST_LEI_ERR_LOUD=1
2021-03-17extindex: add some validation and config knobs for WWW
We'll try to share a bit more configuration with extindex entries for WWW PSGI usage.
2021-03-15t/convert-compact: create_inbox
Suprisingly, this saves over 100 milliseconds.
2021-03-15test_common: minor simplifications to setup_public_inboxes
This will results in a small reduction in on-disk footprint by removing Xapian docdata and reduction in code by removing an unnecessary -index invocation.
2021-03-15test_common: add create_inbox helper sub
This saves over 100ms in t/lei-q-remote-import.t so far when TMPDIR is on an SSD. If we can memoize inbox creation to save a few dozen milliseconds every test, this could add up to noticeable savings across our entire test suite.
2021-02-26test_common: io_modes: always support read/write
This avoids warnings when redirecting STDIN to a scalarref via run_script().
2021-02-24treewide: avoid "delete local" construct on hashes
Apparently this feature is only in Perl 5.12+, and we're still on Perl 5.10.
2021-02-22t/lei*: drop $lei->(...) sub
lei() and lei_ok() are superior since they offer prototype checks and lei_ok() adds another check + description DRY-ness. The $lei sub was only bound to a variable since it was in t/lei.t and named subs don't work well with the key2sub() wrapper.
2021-02-18lei convert: mail format conversion sub-command
This will make testing IMAP support for other commands easier, as it doesn't write to lei/store at all. Like the pager and MUA, "git credential" is always spawned by script/lei (and not lei-daemon) so it has a controlling terminal for password prompts. v2: fix missing requires, correct test ordering v3: ensure config exists for IMAP auth
2021-02-18tests: setup_public_inboxes: use IMAP-friendly newsgroups
-imapd won't support newsgroups ending with /\.[0-9]+\z/ since it reserves those for partitioning inboxes into 50K slices. So bump the home[0-9]+ version and switch to IMAP-friendly newsgroup names.
2021-02-10tests: skip properly with git <2.6
Tested with git 1.8.3.1 on CentOS 7.x `plan skip_all => ...' doesn't work after some tests have run, we have to call skip() instead.
2021-02-10lei ls-external: support --local and --remote
Similar to "lei q", "--local" means only local and "--remote" means remote only. I can't think of a reason to have --no-* variants for these switches. There's also updates to the TestCommon for more common lei cases.
2021-02-10test_common: support lei-daemon only testing
Daemon-only tests can be significantly faster due to cached configs; so give developers a chance to test only daemons to improve productivity. The differences between daemon and oneshot modes are minimal, at this point.
2021-02-10tests|lei: fixes for TEST_RUN_MODE=0 and lei oneshot
DESTROY callbacks can clobber $?, so we must take care to preserve it when exiting. We'll also try to make an effort to ensure better DESTROY ordering and delete as much as possible before x_it finishes. We also need to load PublicInbox::Config when setting up public inboxes.
2021-02-10lei: split out MdirReader package, lazy-require earlier
We'll do more requires in the top-level lei-daemon process to save work in workers. We can also work towards aborting on user errors in lei-daemon rather than worker processes. "lei import -f mbox*" is finally tested inside t/lei_to_mail.t
2021-02-10test_common: disable fsync on the CLI where possible
This makes tests faster for users on slow TMPDIR (or not using eatmydata) and forces coverage on a non-default switch. Unfortunately, this doesn't yet cover InboxWritable usage.
2021-02-08tests: favor IPv6
IPv4 gets plenty of real-world coverage, and apparently there's Debian buildd hosts which lack IPv4(*). So ensure everything can work on IPv6 and not cause problems for odd setups. (*) https://bugs.debian.org/979432
2021-02-07lei: add-external --mirror support
This can be useful for users who want to clone and mirror an existing public-inbox. This doesn't have update support, yet, so users will need to run "git fetch && public-inbox-index" for now.
2021-02-07tests: split out lei-daemon.t from lei.t
This makes it easier for hackers to find daemon-specific tests and forces us to always test both daemon and oneshot mode.
2021-02-07t/tests: split out setup_public_inboxes sub
We'll probably use this in many more existing places and likely change non-lei tests to use it.