about summary refs log tree commit homepage
path: root/t/lei.t
DateCommit message (Collapse)
2023-10-17lei: consolidate stdin slurp, fix warnings
We can share more code amongst stdin slurper (not streaming) commands. This also fixes uninitialized variable warnings when feeding an empty stdin to these commands.
2023-09-24lei: fix `-c NAME=VALUE' config support
We can pass `-c NAME=VALUE' args directly to git-config without needing a temporary directory nor file. Furthermore, this opens the door to us being able to correctly handle `-c NAME=VALUE' after `delete $lei->{cfg}' if we need to reload the config during a command. This tightens up error-checking for `lei config' and ensures we can make config settings changes while using `-c NAME=VALUE' instead of editing the temporary file. The non-obvious part was avoiding the use of the -f/--file arg for `git config' for read-only operations and include relying on `-c include.path=$ABS_PATH'. This is done by parsing the switches to be passed to `git config' to determine if it's a read-only operation or not.
2023-09-16lei q: set exit code for invalid Xapian queries
Xapian can't parse every query, so ensure we set the exit code for the client.
2023-09-05tests: add `+SCM_RIGHTS' as a require_mods target
We'll also ensure the existing `lei' target expands to depend on `+SCM_RIGHTS', and use require_mods in t/lei-import-nntp.t and t/lei.t so they can be skipped when Inline::C and Socket::MsgHdr are missing on OpenBSD.
2023-06-09t/lei.t: quiet newline warning on older Perls
Perl < 5.22 warned on newlines in the middle of a string instead of just the end. Workaround it by disabling all warnings on older Perls while running File::Path::mkpath.
2022-12-02lei: stricter external checks for valid $GIT_DIR/objects
I ended up with my $HOME in ~/.cache/lei/all_locals_ever.git/objects/info/alterntes and am trying to avoid that in the future.
2021-11-10lei q: disallow "\n" in argv[] elements
I don't expect this to be hit in real-world use via normal interactive shells. However, somebody could accidentally add "\n" in languages (e.g. Perl, C) where it's easy to pass "\n" in argv[].
2021-10-16t/lei*: set EDITOR for dumb terminals
Running tests over a non-interactive ssh session fails, otherwise.
2021-09-19lei config --edit: use controlling terminal
As with "lei edit-search", "lei config --edit" may spawn an interactive editor which works best from the terminal running script/lei. So implement LeiConfig as a superclass of LeiEditSearch so the two commands can share the same verification hooks and retry logic.
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-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-08-19lei q: make --save the default
Since "lei up" is more often useful than not and incurs neglible overhead; enable --save by default and allow --no-save to work. This also fixes a long-standing when overwriting --output destinations with saved searches: dedupe data from previous searches are reset and no longer influences the new (changed) search, so results no longer go missing if two sequential invocations of "lei q --save" point to the same --output.
2021-04-28lei: avoid close(STD{IN,OUT,ERR}) in oneshot mode
This seems to fix the occasional "make check-run" failures I've been chasing. Some parts of our code assumes we can close($lei->{1}) and similar, which causes IO::Handle::autoflush to behave badly when STDOUT is the "select"-ed FH of the Perl process. Since oneshot mode is (hopefully) the uncommon case, we'll just accept the cost of extra FDs and minimize differences between lei in oneshot vs daemon mode.
2021-04-22lei import|convert: drop --no-kw aliases
Supporting --no-keywords and --no-flags aliases is harmful if users end up assuming "keywords:" and "flags:" are valid search prefixes (they're not).
2021-04-13lei q: start wiring up saved search
This will have a over.sqlite3 for content-based deduplication. It may exhibit ibxish methods, so serving a read-only (or even R/W) IMAP or instance or displaying HTML isn't outside the realm of possibility.
2021-04-01lei sucks: sub-command to aid bug reporting
It's a bit of an Easter egg, though it's not possible to hide those in Free Software... Anyways, it doesn't cost us an entry in %CMD of LEI.pm and anybody frustrated enough with lei just might type "lei sucks" on the command-line :>
2021-03-23lei: support -c <name>=<value> to overrides
It's a bit nasty, but seems to mostly work for debugging IMAP and NNTP commands.
2021-03-19lei: disallow "\n" in local externals paths
git 2.11 and earlier could not handle git directories with newlines in them, nor does libgit2 support them. Followup-to: d87dd0e679587043 ("config: reject `\n' in `inboxdir'")
2021-03-04lei q: import flags when clobbering/augmenting Maildirs
This will eventually be supported for other mail stores, but Maildir is the easiest to test and support, here. This lets us avoid a situation where flag changes get lost between search results.
2021-02-23lei: support "-C" to chdir in all sub commands
We'll also support "-C" at the end of most commands to give users a little more flexibility when building command-lines. This conflicts with "lei daemon-kill -CHLD", so that's special-cased since "-C" makes no sense with daemon-kill, anyways. Unlike "git show", the to-be-implemented "lei show" will diverge and enable "--find-copies[=<n>]" by default, so "-C[<n>]" won't be necessary.
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-10lei: replace "I:"-prefixed info messages with "#"
The "#" is what TAP <https://testanything.org/> uses, which is also consistent with what our (and many other) test suites emit.
2021-02-07lei: remove --mua-cmd alias for --mua
While "mua-cmd" may be more accurate, nobody is expected to type 4 extra characters. It's a needless ambiguity with no precedence or prior art to follow. Link: https://public-inbox.org/meta/20210206090119.GA14519@dcvr/
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/lei-externals: split out into separate test
This is still overloaded with "lei q" stuff, but that's somewhat inevitable.
2021-02-07tests: add test_lei wrapper, split out t/lei-import.t
This will make it easier to maintain and test lei going forward, we need to be testing against existing read-only daemons. We'll also save ourselves some boilerplate by exporting all the Test::More methods directly in TestCommon We'll start using this by splitting out the latest "lei import" tests into its own file.
2021-02-07lei: fix completion of --no-kw / --no-keywords
We did not complete --no-* flags properly when multiple options are allowed.
2021-02-07lei: favor "keywords" over "flags", test --no-kw
JMAP brain says "keywords", IMAP brain says "flags"; JMAP brain wins today. Since "keywords" is a bit long, support "kw" as a shortcut since there's no conflict and "kw:" will be our search prefix for looking up messages by keyword.
2021-02-05lei import: initial implementation
Only tested with .eml files so far, but Maildir + IMAP will be supported.
2021-02-04t/lei: skip "lei q" tests on missing dependencies
... for now. It's probably possible to just use send() recv() without CMSG_* eventually.
2021-02-04lei q: support reading queries from stdin
This will be useful on shared machines when a user doesn't want search queries visible to other users looking at the ps(1) output or similar.
2021-02-04lei add-external: completion for existing URL basenames
Given the presence of one external on a certain host or prefix path, it's logical other inboxes would share a common prefix. For bash users, attempt to complete that using the "-o nospace" option of bash
2021-02-04lei: propagate curl errors, improve internal consistency
IO::Uncompress::Gunzip seems to be losing $? when closing PublicInbox::ProcessPipe. To workaround this, do a synchronous waitpid ourselves to force proper $? reporting update tests to use the new --only feature for testing invalid URLs. This improves internal code consistency by having {pkt_op} parse the same ASCII-only protocol script/lei understands. We no longer pass {sock} to worker processes at all, further reducing FD pressure on per-user limits.
2021-02-03lei: q: shell completion for --(include|exclude|only)
Because .onion URLs names are long!
2021-02-03lei q: emit progress and counting via PktOp
Sometimes it can be confusing for "lei q" to finish writing to a Maildir|mbox and not know if it did anything. So show some per-external progress and stats. These can be disabled via the new --quiet/-q switch. We differ slightly from mairix(1) here, as we use stderr instead of stdout for reporting totals (and we support parallel queries from various sources).
2021-01-29lei: complete option switch args
And add tests for existing completion cases
2021-01-26lei q: demangle and quiet curl output
curl(1) writes to stderr one byte-at-a-time (presumably for the progress bar). This ends up being unreadable on my terminal when parallel processes are trying to write error messages. So instead, we'll capture the output to a file and run 'tail -f' on it if --verbose is enabled. Since HTTP 404s from non-existent results are a common response, we'll ignore them and stay silent, matching behavior of local searches.
2021-01-26lei: reinstate JSON smsg output deduplication
This was accidentally clobbered completely in ("lei q: fix JSON overview with remote externals"). There are now more tests to prevent future regressions.
2021-01-24lei q: honor --no-local to force remote searches
This can be useful for testing remote behavior, or for augmenting local results. It'll also be possible to explicitly include/exclude externals via CLI switches (once names are decided).
2021-01-24lei add-external: don't allow non-existent directories
At least not yet, though we may support mirroring via git.
2021-01-23lei: support remote externals
Via curl(1), since that lets us easily use tor on a per-connection basis via LD_PRELOAD (torsocks) or proxy. We'll eventually support more curl options which can allow users to get past firewalls and deal with other odd network configurations.
2021-01-22lei: forget-external support with canonicalization
For proper matching, we'll do a better job canonicalizing URLs and path names for matching. Of course, users may edit the file outside of lei, so ensure we try both the canonicalized and as-is form provided by the user. I also don't think we'll need to store externals info in MiscIdx; just the config file is fine.
2021-01-21lei: dump and clear errors.log in daemon mode
Inspired by "dmesg -c", this should help users report bugs and avoids eating up $XDG_RUNTIME_DIR. Once lei is ready for release, hopefully the need for this should be few an far between, but shit happens.
2021-01-21lei: allow more mbox inode types
We may attempt to write an mbox to any terminal, block, or character device, not just regular files and FIFOs/pipes. The only thing that is known to not work is a directory. Sockets may be possible with some OSes (e.g. Plan 9) or filesystems. This fixes t/lei.t on FreeBSD 11.x
2021-01-21lei_overview: start implementing format detection
We'll need it for IMAP support, at least. Proper mbox family detection will be expensive, so deal with it later.
2021-01-21lei: test some likely errors due to misuse
Because user errors happen...
2021-01-21t/lei: fix double-running of socket test with oneshot
We split out t/lei-oneshot.t and t/lei.t so it's easier to isolate run-mode specific bugs and behavior and there's no reason to rerun the socket daemon tests.
2021-01-21lei q: fix augment of compressed mailboxes
We need to delay writing out the mailbox until the compressor process is up and running, so have startq wait a bit. This means we must create the pipe early and hand it off to the workers before augmenting, despite spawning the gzip/pigz/xz/bzip2 process after augment is complete.
2021-01-18lei: q: results output to Maildir and mbox* working
All the augment and deduplication stuff seems to be working based on unit tests. OpPipe is a nice general addition that will probably make future state machines easier.
2021-01-15lei: pass FD to CWD via cmsg, use fchdir on server
Perl chdir() automatically does fchdir(2) if given a file or directory handle since 5.8.8/5.10.0, so we can safely rely on it given our 5.10.1+ requirement. This means we no longer have to waste several milliseconds loading the Cwd.so and making stat() calls to ensure ENV{PWD} is correct and usable in the server. It also lets us work in directories that are no longer accessible via pathname.