unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
blob 7621e7f2ecebce00838b119047c1136b0d034025 2123 bytes (raw)
name: test/T560-lib-error.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
 
#!/usr/bin/env bash
test_description="error reporting for library"

. ./test-lib.sh

add_email_corpus

test_expect_success "building database" "NOTMUCH_NEW"

test_begin_subtest "Open null pointer"
test_C <<EOF
#include <stdio.h>
#include <notmuch.h>
int main (int argc, char** argv)
{
    notmuch_database_t *db;
    notmuch_status_t stat;
    stat = notmuch_database_open (NULL, 0, 0);
}
EOF
cat <<EOF >EXPECTED
== stdout ==
== stderr ==
Error: Cannot open a database for a NULL path.
EOF
test_expect_equal_file EXPECTED OUTPUT

test_begin_subtest "Open nonexistent database"
test_C <<EOF
#include <stdio.h>
#include <notmuch.h>
int main (int argc, char** argv)
{
    notmuch_database_t *db;
    notmuch_status_t stat;
    stat = notmuch_database_open ("/nonexistent/foo", 0, 0);
}
EOF
cat <<EOF >EXPECTED
== stdout ==
== stderr ==
Error opening database at /nonexistent/foo/.notmuch: No such file or directory
EOF
test_expect_equal_file EXPECTED OUTPUT

test_begin_subtest "Write to read-only database"
test_C ${MAIL_DIR} <<EOF
#include <stdio.h>
#include <notmuch.h>
int main (int argc, char** argv)
{
   notmuch_database_t *db;
   notmuch_status_t stat;
   stat = notmuch_database_open (argv[1], NOTMUCH_DATABASE_MODE_READ_ONLY, &db);
   if (stat != NOTMUCH_STATUS_SUCCESS) {
     fprintf (stderr, "error opening database: %d\n", stat);
   }
   stat = notmuch_database_add_message (db, "/dev/null", NULL);
   if (stat)
       fputs (notmuch_database_status_string (db), stderr);

}
EOF
cat <<EOF >EXPECTED
== stdout ==
== stderr ==
Cannot write to a read-only database.
EOF
test_expect_equal_file EXPECTED OUTPUT

test_begin_subtest "compact, overwriting existing backup"
test_C ${MAIL_DIR} <<EOF
#include <stdio.h>
#include <notmuch.h>
static void
status_cb (const char *msg, void *closure)
{
    printf ("%s\n", msg);
}
int main (int argc, char** argv)
{
   notmuch_database_t *db;
   notmuch_status_t stat;
   stat = notmuch_database_compact (argv[1], argv[1], status_cb, NULL);
}
EOF
cat <<EOF >EXPECTED
== stdout ==
Path already exists: CWD/mail

== stderr ==
EOF
test_expect_equal_file EXPECTED OUTPUT

test_done

debug log:

solving 7621e7f ...
found 7621e7f in https://yhetil.org/notmuch/1426352554-4383-9-git-send-email-david@tethera.net/
found dc2022f in https://yhetil.org/notmuch/1426352554-4383-4-git-send-email-david@tethera.net/

applying [1/2] https://yhetil.org/notmuch/1426352554-4383-4-git-send-email-david@tethera.net/
diff --git a/test/T560-lib-error.sh b/test/T560-lib-error.sh
new file mode 100755
index 0000000..dc2022f


applying [2/2] https://yhetil.org/notmuch/1426352554-4383-9-git-send-email-david@tethera.net/
diff --git a/test/T560-lib-error.sh b/test/T560-lib-error.sh
index dc2022f..7621e7f 100755

Checking patch test/T560-lib-error.sh...
Applied patch test/T560-lib-error.sh cleanly.
Checking patch test/T560-lib-error.sh...
Applied patch test/T560-lib-error.sh cleanly.

index at:
100755 7621e7f2ecebce00838b119047c1136b0d034025	test/T560-lib-error.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).