[PATCH] test: cli: getting/setting/removing config values

2012-01-16 Thread Pieter Praet
On Mon, 16 Jan 2012 07:37:13 -0400, David Bremner  wrote:
> On Mon, 16 Jan 2012 11:31:11 +0100, Pieter Praet  wrote:
> > 
> > Hmmm, `dnsdomainname' returns "(none)" here;  Does it work for you?
> > 
> > Running `domainname' instead seems to do the right thing though...
> > 
> 
> I make no claims to have "correctly" configured this machine on my home
> network, [...]

Same here :)

> [...] but here it is the opposite.  The docs refer to NIS for
> domainname, which I guess is not _that_ common for home networks (or at
> all anymore?).
> 

$ grep hosts /etc/nsswitch.conf
hosts: files dns

I guess that's a no.

> d


Perhaps others could chime in?


Peace

-- 
Pieter


[PATCH] test: cli: getting/setting/removing config values

2012-01-16 Thread Pieter Praet
On Sat, 14 Jan 2012 08:16:30 -0400, David Bremner  wrote:
> On Sat, 14 Jan 2012 09:57:56 +0100, Pieter Praet  wrote:
> > Full test coverage for getting, setting and removing options in
> > notmuch(1)'s config file ($NOTMUCH_CONFIG or $HOME/.notmuch-config).
> > 
> > ---
> > +
> > +# FIXME: Not the most robust nor portable solution here...
> > +# Especially `hostname --domain' may have unwanted effects on
> > +# some platforms, e.g. setting your hostname to "--domain" ;)
> > +fallback_name="$(grep $(id -un) /etc/passwd | cut -d ":" -f 5 | cut -d "," 
> > -f 1)"
> > +fallback_email="$(id -un)@$(hostname).$(hostname --domain)"
> 
> I'm not sure how portable it is, but maybe dnsdomainname would at least
> have better failure modes.
> 

Hmmm, `dnsdomainname' returns "(none)" here;  Does it work for you?

Running `domainname' instead seems to do the right thing though...


It would probably be safest to simply mirror how it's done @
notmuch-config.c:313, but that seems rather excessive.

> I also wondered about using getent instead of grep.
> 

Agreed, much safer;  `grep' might return multiple results.

> d

How about this? :

  #+begin_src sh
fallback_name="$(getent passwd ${USER} | cut -d ":" -f 5 | cut -d "," -f 1)"
test -n "${EMAIL}" \
&& fallback_email="${EMAIL}" \
|| fallback_email="${USER}@$(hostname).$(domainname)"
  #+end_src


Peace

-- 
Pieter


Re: [PATCH] test: cli: getting/setting/removing config values

2012-01-16 Thread Pieter Praet
On Mon, 16 Jan 2012 07:37:13 -0400, David Bremner  wrote:
> On Mon, 16 Jan 2012 11:31:11 +0100, Pieter Praet  wrote:
> > 
> > Hmmm, `dnsdomainname' returns "(none)" here;  Does it work for you?
> > 
> > Running `domainname' instead seems to do the right thing though...
> > 
> 
> I make no claims to have "correctly" configured this machine on my home
> network, [...]

Same here :)

> [...] but here it is the opposite.  The docs refer to NIS for
> domainname, which I guess is not _that_ common for home networks (or at
> all anymore?).
> 

$ grep hosts /etc/nsswitch.conf
hosts: files dns

I guess that's a no.

> d


Perhaps others could chime in?


Peace

-- 
Pieter
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH] test: cli: getting/setting/removing config values

2012-01-16 Thread David Bremner
On Mon, 16 Jan 2012 11:31:11 +0100, Pieter Praet  wrote:
> 
> Hmmm, `dnsdomainname' returns "(none)" here;  Does it work for you?
> 
> Running `domainname' instead seems to do the right thing though...
> 

I make no claims to have "correctly" configured this machine on my home
network, but here it is the opposite.  The docs refer to NIS for
domainname, which I guess is not _that_ common for home networks (or at
all anymore?).

d


Re: [PATCH] test: cli: getting/setting/removing config values

2012-01-16 Thread David Bremner
On Mon, 16 Jan 2012 11:31:11 +0100, Pieter Praet  wrote:
> 
> Hmmm, `dnsdomainname' returns "(none)" here;  Does it work for you?
> 
> Running `domainname' instead seems to do the right thing though...
> 

I make no claims to have "correctly" configured this machine on my home
network, but here it is the opposite.  The docs refer to NIS for
domainname, which I guess is not _that_ common for home networks (or at
all anymore?).

d
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] test: cli: getting/setting/removing config values

2012-01-16 Thread Pieter Praet
On Sat, 14 Jan 2012 08:16:30 -0400, David Bremner  wrote:
> On Sat, 14 Jan 2012 09:57:56 +0100, Pieter Praet  wrote:
> > Full test coverage for getting, setting and removing options in
> > notmuch(1)'s config file ($NOTMUCH_CONFIG or $HOME/.notmuch-config).
> > 
> > ---
> > +
> > +# FIXME: Not the most robust nor portable solution here...
> > +# Especially `hostname --domain' may have unwanted effects on
> > +# some platforms, e.g. setting your hostname to "--domain" ;)
> > +fallback_name="$(grep $(id -un) /etc/passwd | cut -d ":" -f 5 | cut -d "," 
> > -f 1)"
> > +fallback_email="$(id -un)@$(hostname).$(hostname --domain)"
> 
> I'm not sure how portable it is, but maybe dnsdomainname would at least
> have better failure modes.
> 

Hmmm, `dnsdomainname' returns "(none)" here;  Does it work for you?

Running `domainname' instead seems to do the right thing though...


It would probably be safest to simply mirror how it's done @
notmuch-config.c:313, but that seems rather excessive.

> I also wondered about using getent instead of grep.
> 

Agreed, much safer;  `grep' might return multiple results.

> d

How about this? :

  #+begin_src sh
fallback_name="$(getent passwd ${USER} | cut -d ":" -f 5 | cut -d "," -f 1)"
test -n "${EMAIL}" \
&& fallback_email="${EMAIL}" \
|| fallback_email="${USER}@$(hostname).$(domainname)"
  #+end_src


Peace

-- 
Pieter
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH] test: cli: getting/setting/removing config values

2012-01-14 Thread Pieter Praet
Full test coverage for getting, setting and removing options in
notmuch(1)'s config file ($NOTMUCH_CONFIG or $HOME/.notmuch-config).

---
Please *do* take note of the FIXME in the last test!

 test/config   |   88 +
 test/notmuch-test |1 +
 2 files changed, 89 insertions(+), 0 deletions(-)
 create mode 100755 test/config

diff --git a/test/config b/test/config
new file mode 100755
index 000..ee3126c
--- /dev/null
+++ b/test/config
@@ -0,0 +1,88 @@
+#!/usr/bin/env bash
+test_description='notmuch config'
+. ./test-lib.sh
+
+
+config_options=(
+"database.path"
+"user.name"
+"user.primary_email"
+"user.other_email"
+"new.tags"
+"maildir.synchronize_flags"
+)
+
+
+test_begin_subtest 'getting config: "config get ."'
+echo -n "" > OUTPUT
+for i in ${config_options[*]} ; do
+notmuch config get "${i}"
+done >> OUTPUT
+cat >EXPECTED <. [values ...]"'
+notmuch config set database.path /path/to/maildir
+notmuch config set user.name "User Name"
+notmuch config set user.primary_email primary_email at notmuchmail.org
+notmuch config set user.other_email alt1 at notmuchmail.org alt2 at 
notmuchmail.org
+notmuch config set new.tags tag1 tag2 tag3
+notmuch config set maildir.synchronize_flags false
+echo -n "" > OUTPUT
+for i in ${config_options[*]} ; do
+notmuch config get "${i}"
+done >> OUTPUT
+cat >EXPECTED <."'
+notmuch config set database.path
+notmuch config set user.name
+notmuch config set user.primary_email
+notmuch config set user.other_email
+notmuch config set new.tags
+notmuch config set maildir.synchronize_flags
+echo -n "" > OUTPUT
+for i in ${config_options[*]} ; do
+notmuch config get "${i}"
+done >> OUTPUT
+
+# FIXME: Not the most robust nor portable solution here...
+# Especially `hostname --domain' may have unwanted effects on
+# some platforms, e.g. setting your hostname to "--domain" ;)
+fallback_name="$(grep $(id -un) /etc/passwd | cut -d ":" -f 5 | cut -d "," -f 
1)"
+fallback_email="$(id -un)@$(hostname).$(hostname --domain)"
+
+cat >EXPECTED <

[PATCH] test: cli: getting/setting/removing config values

2012-01-14 Thread Pieter Praet
On Thu, 12 Jan 2012 23:42:04 -0400, David Bremner  wrote:
> On Thu, 12 Jan 2012 18:30:01 +0100, Pieter Praet  wrote:
> > Should have come before commit 1df71b55
> 
> This doesn't seem like an especially helpful commit
> message. Editorializing is ok, I guess, but maybe keep it below the
> '---' ?
> 

You're right.  The message I was trying to convey (quite tersely),
was that these tests were written in response to commit 1df71b55
(and should probably be retroactively ran on 1df71b55~1).

I realize now that it could potentially be wrongly interpreted as
criticism of sorts, which of course wasn't my intention.

Anyways, I ran the tests on both 1df71b55~1 and 1df71b55, and
-as expected- everything checks out fine.

Amended patch follows.

> d


Peace

-- 
Pieter


[PATCH] test: cli: getting/setting/removing config values

2012-01-14 Thread David Bremner
On Sat, 14 Jan 2012 09:57:56 +0100, Pieter Praet  wrote:
> Full test coverage for getting, setting and removing options in
> notmuch(1)'s config file ($NOTMUCH_CONFIG or $HOME/.notmuch-config).
> 
> ---
> +
> +# FIXME: Not the most robust nor portable solution here...
> +# Especially `hostname --domain' may have unwanted effects on
> +# some platforms, e.g. setting your hostname to "--domain" ;)
> +fallback_name="$(grep $(id -un) /etc/passwd | cut -d ":" -f 5 | cut -d "," 
> -f 1)"
> +fallback_email="$(id -un)@$(hostname).$(hostname --domain)"

I'm not sure how portable it is, but maybe dnsdomainname would at least
have better failure modes.

I also wondered about using getent instead of grep.

d


Re: [PATCH] test: cli: getting/setting/removing config values

2012-01-14 Thread David Bremner
On Sat, 14 Jan 2012 09:57:56 +0100, Pieter Praet  wrote:
> Full test coverage for getting, setting and removing options in
> notmuch(1)'s config file ($NOTMUCH_CONFIG or $HOME/.notmuch-config).
> 
> ---
> +
> +# FIXME: Not the most robust nor portable solution here...
> +# Especially `hostname --domain' may have unwanted effects on
> +# some platforms, e.g. setting your hostname to "--domain" ;)
> +fallback_name="$(grep $(id -un) /etc/passwd | cut -d ":" -f 5 | cut -d "," 
> -f 1)"
> +fallback_email="$(id -un)@$(hostname).$(hostname --domain)"

I'm not sure how portable it is, but maybe dnsdomainname would at least
have better failure modes.

I also wondered about using getent instead of grep.

d
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH] test: cli: getting/setting/removing config values

2012-01-14 Thread Pieter Praet
Full test coverage for getting, setting and removing options in
notmuch(1)'s config file ($NOTMUCH_CONFIG or $HOME/.notmuch-config).

---
Please *do* take note of the FIXME in the last test!

 test/config   |   88 +
 test/notmuch-test |1 +
 2 files changed, 89 insertions(+), 0 deletions(-)
 create mode 100755 test/config

diff --git a/test/config b/test/config
new file mode 100755
index 000..ee3126c
--- /dev/null
+++ b/test/config
@@ -0,0 +1,88 @@
+#!/usr/bin/env bash
+test_description='notmuch config'
+. ./test-lib.sh
+
+
+config_options=(
+"database.path"
+"user.name"
+"user.primary_email"
+"user.other_email"
+"new.tags"
+"maildir.synchronize_flags"
+)
+
+
+test_begin_subtest 'getting config: "config get ."'
+echo -n "" > OUTPUT
+for i in ${config_options[*]} ; do
+notmuch config get "${i}"
+done >> OUTPUT
+cat >EXPECTED <. [values ...]"'
+notmuch config set database.path /path/to/maildir
+notmuch config set user.name "User Name"
+notmuch config set user.primary_email primary_em...@notmuchmail.org
+notmuch config set user.other_email a...@notmuchmail.org a...@notmuchmail.org
+notmuch config set new.tags tag1 tag2 tag3
+notmuch config set maildir.synchronize_flags false
+echo -n "" > OUTPUT
+for i in ${config_options[*]} ; do
+notmuch config get "${i}"
+done >> OUTPUT
+cat >EXPECTED <."'
+notmuch config set database.path
+notmuch config set user.name
+notmuch config set user.primary_email
+notmuch config set user.other_email
+notmuch config set new.tags
+notmuch config set maildir.synchronize_flags
+echo -n "" > OUTPUT
+for i in ${config_options[*]} ; do
+notmuch config get "${i}"
+done >> OUTPUT
+
+# FIXME: Not the most robust nor portable solution here...
+# Especially `hostname --domain' may have unwanted effects on
+# some platforms, e.g. setting your hostname to "--domain" ;)
+fallback_name="$(grep $(id -un) /etc/passwd | cut -d ":" -f 5 | cut -d "," -f 
1)"
+fallback_email="$(id -un)@$(hostname).$(hostname --domain)"
+
+cat >EXPECTED 

Re: [PATCH] test: cli: getting/setting/removing config values

2012-01-14 Thread Pieter Praet
On Thu, 12 Jan 2012 23:42:04 -0400, David Bremner  wrote:
> On Thu, 12 Jan 2012 18:30:01 +0100, Pieter Praet  wrote:
> > Should have come before commit 1df71b55
> 
> This doesn't seem like an especially helpful commit
> message. Editorializing is ok, I guess, but maybe keep it below the
> '---' ?
> 

You're right.  The message I was trying to convey (quite tersely),
was that these tests were written in response to commit 1df71b55
(and should probably be retroactively ran on 1df71b55~1).

I realize now that it could potentially be wrongly interpreted as
criticism of sorts, which of course wasn't my intention.

Anyways, I ran the tests on both 1df71b55~1 and 1df71b55, and
-as expected- everything checks out fine.

Amended patch follows.

> d


Peace

-- 
Pieter
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH] test: cli: getting/setting/removing config values

2012-01-12 Thread David Bremner
On Thu, 12 Jan 2012 18:30:01 +0100, Pieter Praet  wrote:
> Should have come before commit 1df71b55

This doesn't seem like an especially helpful commit
message. Editorializing is ok, I guess, but maybe keep it below the
'---' ?

d


Re: [PATCH] test: cli: getting/setting/removing config values

2012-01-12 Thread David Bremner
On Thu, 12 Jan 2012 18:30:01 +0100, Pieter Praet  wrote:
> Should have come before commit 1df71b55

This doesn't seem like an especially helpful commit
message. Editorializing is ok, I guess, but maybe keep it below the
'---' ?

d
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH] test: cli: getting/setting/removing config values

2012-01-12 Thread Pieter Praet
Should have come before commit 1df71b55

---
 test/config   |   88 +
 test/notmuch-test |1 +
 2 files changed, 89 insertions(+), 0 deletions(-)
 create mode 100755 test/config

diff --git a/test/config b/test/config
new file mode 100755
index 000..ee3126c
--- /dev/null
+++ b/test/config
@@ -0,0 +1,88 @@
+#!/usr/bin/env bash
+test_description='notmuch config'
+. ./test-lib.sh
+
+
+config_options=(
+"database.path"
+"user.name"
+"user.primary_email"
+"user.other_email"
+"new.tags"
+"maildir.synchronize_flags"
+)
+
+
+test_begin_subtest 'getting config: "config get ."'
+echo -n "" > OUTPUT
+for i in ${config_options[*]} ; do
+notmuch config get "${i}"
+done >> OUTPUT
+cat >EXPECTED <. [values ...]"'
+notmuch config set database.path /path/to/maildir
+notmuch config set user.name "User Name"
+notmuch config set user.primary_email primary_email at notmuchmail.org
+notmuch config set user.other_email alt1 at notmuchmail.org alt2 at 
notmuchmail.org
+notmuch config set new.tags tag1 tag2 tag3
+notmuch config set maildir.synchronize_flags false
+echo -n "" > OUTPUT
+for i in ${config_options[*]} ; do
+notmuch config get "${i}"
+done >> OUTPUT
+cat >EXPECTED <."'
+notmuch config set database.path
+notmuch config set user.name
+notmuch config set user.primary_email
+notmuch config set user.other_email
+notmuch config set new.tags
+notmuch config set maildir.synchronize_flags
+echo -n "" > OUTPUT
+for i in ${config_options[*]} ; do
+notmuch config get "${i}"
+done >> OUTPUT
+
+# FIXME: Not the most robust nor portable solution here...
+# Especially `hostname --domain' may have unwanted effects on
+# some platforms, e.g. setting your hostname to "--domain" ;)
+fallback_name="$(grep $(id -un) /etc/passwd | cut -d ":" -f 5 | cut -d "," -f 
1)"
+fallback_email="$(id -un)@$(hostname).$(hostname --domain)"
+
+cat >EXPECTED <

[PATCH] test: cli: getting/setting/removing config values

2012-01-12 Thread Pieter Praet
Should have come before commit 1df71b55

---
 test/config   |   88 +
 test/notmuch-test |1 +
 2 files changed, 89 insertions(+), 0 deletions(-)
 create mode 100755 test/config

diff --git a/test/config b/test/config
new file mode 100755
index 000..ee3126c
--- /dev/null
+++ b/test/config
@@ -0,0 +1,88 @@
+#!/usr/bin/env bash
+test_description='notmuch config'
+. ./test-lib.sh
+
+
+config_options=(
+"database.path"
+"user.name"
+"user.primary_email"
+"user.other_email"
+"new.tags"
+"maildir.synchronize_flags"
+)
+
+
+test_begin_subtest 'getting config: "config get ."'
+echo -n "" > OUTPUT
+for i in ${config_options[*]} ; do
+notmuch config get "${i}"
+done >> OUTPUT
+cat >EXPECTED <. [values ...]"'
+notmuch config set database.path /path/to/maildir
+notmuch config set user.name "User Name"
+notmuch config set user.primary_email primary_em...@notmuchmail.org
+notmuch config set user.other_email a...@notmuchmail.org a...@notmuchmail.org
+notmuch config set new.tags tag1 tag2 tag3
+notmuch config set maildir.synchronize_flags false
+echo -n "" > OUTPUT
+for i in ${config_options[*]} ; do
+notmuch config get "${i}"
+done >> OUTPUT
+cat >EXPECTED <."'
+notmuch config set database.path
+notmuch config set user.name
+notmuch config set user.primary_email
+notmuch config set user.other_email
+notmuch config set new.tags
+notmuch config set maildir.synchronize_flags
+echo -n "" > OUTPUT
+for i in ${config_options[*]} ; do
+notmuch config get "${i}"
+done >> OUTPUT
+
+# FIXME: Not the most robust nor portable solution here...
+# Especially `hostname --domain' may have unwanted effects on
+# some platforms, e.g. setting your hostname to "--domain" ;)
+fallback_name="$(grep $(id -un) /etc/passwd | cut -d ":" -f 5 | cut -d "," -f 
1)"
+fallback_email="$(id -un)@$(hostname).$(hostname --domain)"
+
+cat >EXPECTED