diff options
author | Eric Wong <e@80x24.org> | 2023-11-28 14:56:21 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2023-11-29 02:13:22 +0000 |
commit | 67ecd56a0aaf977fa1a22aa6e2378c9317c72549 (patch) | |
tree | edb6e7d87ab1bc1b05bde1e5eb07d9b1ccab6a21 /t | |
parent | 10b23966ff8fa35a112f7fe2b9386dd4967d818c (diff) | |
download | public-inbox-67ecd56a0aaf977fa1a22aa6e2378c9317c72549.tar.gz |
This is a major step in solving the problem of having to manually associate hundreds/thousands of coderepos with hundreds/thousands of public-inboxes to power solver (and more).
Diffstat (limited to 't')
-rw-r--r-- | t/cindex.t | 28 |
1 files changed, 26 insertions, 2 deletions
@@ -5,7 +5,7 @@ use v5.12; use PublicInbox::TestCommon; use Cwd qw(getcwd abs_path); use List::Util qw(sum); -use autodie qw(close open rename); +use autodie qw(close mkdir open rename); require_mods(qw(json Xapian +SCM_RIGHTS)); use_ok 'PublicInbox::CodeSearchIdx'; use PublicInbox::Import; @@ -227,7 +227,7 @@ SKIP: { # --prune } File::Path::remove_tree("$tmp/ext"); -ok(mkdir("$tmp/ext", 0707), 'create $tmp/ext with odd permissions'); +mkdir("$tmp/ext", 0707); ok(run_script([qw(-cindex --dangerous -q -d), "$tmp/ext", $zp]), 'external on existing dir'); { @@ -265,4 +265,28 @@ EOM 'non-Xapian-enabled inbox noted'); } +# we need to support blank sections for a top-level repos +# (e.g. <https://example.com/my-project> +# git.kernel.org could use "pub" as section name, though, since all git repos +# are currently under //git.kernel.org/pub/**/* +{ + mkdir(my $d = "$tmp/blanksection"); + my $cfg = cfg_new($d, <<EOM); +[cindex ""] + topdir = $tmp/ext + localprefix = $tmp +EOM + my $csrch = $cfg->lookup_cindex(''); + is ref($csrch), 'PublicInbox::CodeSearch', 'codesearch w/ blank name'; + is_deeply $csrch->{localprefix}, [ "$tmp" ], 'localprefix respected'; + my $nr = 0; + $cfg->each_cindex(sub { + my ($cs, @rest) = @_; + is $cs->{topdir}, $csrch->{topdir}, 'each_cindex works'; + is_deeply \@rest, [ '.' ], 'got expected arg'; + ++$nr; + }, '.'); + is $nr, 1, 'iterated through cindices'; +} + done_testing; |