-my $test_lei_oneshot = $ENV{TEST_LEI_ONESHOT};
-SKIP: {
- last SKIP if $test_lei_oneshot;
- require_mods('IO::FDPass', 16);
- my $sock = "$ENV{XDG_RUNTIME_DIR}/lei/sock";
-
- ok(run_script([qw(lei daemon-pid)], undef, $opt), 'daemon-pid');
- is($err, '', 'no error from daemon-pid');
- like($out, qr/\A[0-9]+\n\z/s, 'pid returned') or BAIL_OUT;
- chomp(my $pid = $out);
- ok(kill(0, $pid), 'pid is valid');
- ok(-S $sock, 'sock created');
-
- $test_lei_common->();
-
- $out = '';
- ok(run_script([qw(lei daemon-pid)], undef, $opt), 'daemon-pid');
- chomp(my $pid_again = $out);
- is($pid, $pid_again, 'daemon-pid idempotent');
-
- ok(run_script([qw(lei daemon-stop)], undef, $opt), 'daemon-stop');
- is($out, '', 'no output from daemon-stop');
- is($err, '', 'no error from daemon-stop');
- for (0..100) {
- kill(0, $pid) or last;
- tick();
+my $test_config = sub {
+ $cleanup->();
+ lei_ok(qw(config a.b c), \'config set var');
+ is($lei_out.$lei_err, '', 'no output on var set');
+ lei_ok(qw(config -l), \'config -l');
+ is($lei_err, '', 'no errors on listing');
+ is($lei_out, "a.b=c\n", 'got expected output');
+ ok(!lei(qw(config -f), "$home/.config/f", qw(x.y z)),
+ 'config set var with -f fails');
+ like($lei_err, qr/not supported/, 'not supported noted');
+ ok(!-f "$home/config/f", 'no file created');
+
+ lei_ok(qw(-c imap.debug config --bool imap.debug));
+ is($lei_out, "true\n", "-c sets w/o value");
+ lei_ok(qw(-c imap.debug=1 config --bool imap.debug));
+ is($lei_out, "true\n", "-c coerces value");
+ lei_ok(qw(-c imap.debug=tr00 config imap.debug));
+ is($lei_out, "tr00\n", "-c string value passed as-is");
+ lei_ok(qw(-c imap.debug=a -c imap.debug=b config --get-all imap.debug));
+ is($lei_out, "a\nb\n", '-c and --get-all work together');
+
+ lei_ok([qw(config -e)], { VISUAL => 'cat', EDITOR => 'cat' });
+ is($lei_out, "[a]\n\tb = c\n", '--edit works');
+};
+
+my $test_completion = sub {
+ lei_ok(qw(_complete lei), \'no errors on complete');
+ my %out = map { $_ => 1 } split(/\s+/s, $lei_out);
+ ok($out{'q'}, "`lei q' offered as completion");
+ ok($out{'add-external'}, "`lei add-external' offered as completion");
+
+ lei_ok(qw(_complete lei q), \'complete q (no args)');
+ %out = map { $_ => 1 } split(/\s+/s, $lei_out);
+ for my $sw (qw(-f --format -o --output --mfolder --augment -a
+ --mua --no-local --local --verbose -v
+ --save --no-save --no-remote --remote --torsocks
+ --reverse -r )) {
+ ok($out{$sw}, "$sw offered as `lei q' completion");