From 67ecd56a0aaf977fa1a22aa6e2378c9317c72549 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 28 Nov 2023 14:56:21 +0000 Subject: www: load and use cindex join data 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). --- t/cindex.t | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) (limited to 't') diff --git a/t/cindex.t b/t/cindex.t index a9075092..29d88ca8 100644 --- a/t/cindex.t +++ b/t/cindex.t @@ -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. +# 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, <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; -- cgit v1.2.3-24-ge0c7