unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
blob 5af1291635114c4b0d884cf92948ce840c684007 2738 bytes (raw)
name: test/T410-argument-parsing.sh 	 # note: path name is non-authoritative(*)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
 
#!/usr/bin/env bash
test_description="argument parsing"
. $(dirname "$0")/test-lib.sh || exit 1

if [[ -n ${NOTMUCH_TEST_INSTALLED} ]]; then
    test_done
fi

test_begin_subtest "sanity check"
$TEST_DIRECTORY/arg-test pos1 --keyword=one --boolean --string=foo pos2 --int=7 --flag=one --flag=three > OUTPUT
cat <<EOF > EXPECTED
boolean 1
keyword 1
flags 5
int 7
string foo
positional arg 1 pos1
positional arg 2 pos2
EOF
test_expect_equal_file EXPECTED OUTPUT

test_begin_subtest "sanity check zero values"
$TEST_DIRECTORY/arg-test --keyword=zero --boolean=false --int=0 > OUTPUT
cat <<EOF > EXPECTED
boolean 0
keyword 0
int 0
EOF
test_expect_equal_file EXPECTED OUTPUT

test_begin_subtest "space instead of = between parameter name and value"
# Note: spaces aren't allowed for booleans. false turns into a positional arg!
$TEST_DIRECTORY/arg-test --keyword one --boolean false --string foo --int 7 --flag one --flag three > OUTPUT
cat <<EOF > EXPECTED
boolean 1
keyword 1
flags 5
int 7
string foo
positional arg 1 false
EOF
test_expect_equal_file EXPECTED OUTPUT

test_begin_subtest "--boolean=true"
$TEST_DIRECTORY/arg-test --boolean=true > OUTPUT
cat <<EOF > EXPECTED
boolean 1
EOF
test_expect_equal_file EXPECTED OUTPUT

test_begin_subtest "--boolean=false"
$TEST_DIRECTORY/arg-test --boolean=false > OUTPUT
cat <<EOF > EXPECTED
boolean 0
EOF
test_expect_equal_file EXPECTED OUTPUT

test_begin_subtest "--no-boolean"
$TEST_DIRECTORY/arg-test --no-boolean > OUTPUT
cat <<EOF > EXPECTED
boolean 0
EOF
test_expect_equal_file EXPECTED OUTPUT

test_begin_subtest "--no-flag"
$TEST_DIRECTORY/arg-test --flag=one --flag=three --no-flag=three > OUTPUT
cat <<EOF > EXPECTED
flags 1
EOF
test_expect_equal_file EXPECTED OUTPUT

test_begin_subtest "test keyword arguments without value"
$TEST_DIRECTORY/arg-test --boolkeyword bananas > OUTPUT
cat <<EOF > EXPECTED
boolkeyword 1
positional arg 1 bananas
EOF
test_expect_equal_file EXPECTED OUTPUT

test_begin_subtest "test keyword arguments with non-default value separated by a space"
$TEST_DIRECTORY/arg-test --boolkeyword false bananas > OUTPUT
cat <<EOF > EXPECTED
boolkeyword 0
positional arg 1 bananas
EOF
test_expect_equal_file EXPECTED OUTPUT

test_begin_subtest "test keyword arguments without value at the end"
$TEST_DIRECTORY/arg-test bananas --boolkeyword > OUTPUT
cat <<EOF > EXPECTED
boolkeyword 1
positional arg 1 bananas
EOF
test_expect_equal_file EXPECTED OUTPUT

test_begin_subtest "test keyword arguments without value but with = (should be an error)"
$TEST_DIRECTORY/arg-test bananas --boolkeyword= > OUTPUT 2>&1
cat <<EOF > EXPECTED
Unknown keyword argument "" for option "boolkeyword".
Unrecognized option: --boolkeyword=
EOF
test_expect_equal_file EXPECTED OUTPUT

test_done

debug log:

solving 5af12916 ...
found 5af12916 in https://yhetil.org/notmuch/20211025145753.3031094-2-david@tethera.net/ ||
	https://yhetil.org/notmuch/20230104124145.2882983-4-david@tethera.net/ ||
	https://yhetil.org/notmuch/20230409142627.2216080-5-david@tethera.net/
found d9aa8e2d in https://yhetil.org/notmuch.git/
preparing index
index prepared:
100755 d9aa8e2d01c811b77a0373cde8105e6e32e29965	test/T410-argument-parsing.sh

applying [1/1] https://yhetil.org/notmuch/20211025145753.3031094-2-david@tethera.net/
diff --git a/test/T410-argument-parsing.sh b/test/T410-argument-parsing.sh
index d9aa8e2d..5af12916 100755

Checking patch test/T410-argument-parsing.sh...
Applied patch test/T410-argument-parsing.sh cleanly.

skipping https://yhetil.org/notmuch/20230104124145.2882983-4-david@tethera.net/ for 5af12916
skipping https://yhetil.org/notmuch/20230409142627.2216080-5-david@tethera.net/ for 5af12916
index at:
100755 5af1291635114c4b0d884cf92948ce840c684007	test/T410-argument-parsing.sh

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).