.gitignore: Ignore the compile script too

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
t/: Migrate to BATS

Migrate all the tests to BATS, dropping the hand-rolled TAP-compatible
thing. The new system makes the tests much easier to understand and
maintain.

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
debian: Update after the BATS integration

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
Makefile.am: Add coverage support

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
src/dh-exec.c: Fix a typo

We need a space after the scandir() in the error messages.

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
t/test_help.bats: New testcase

Add a new test case to verify that dh-exec fails gracefully when
DH_EXEC_LIBDIR points to a place that does not exist.

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
t/test_help.bats: New testcase

Add another testcase that verifies that dh-exec fails gracefully when
DH_EXEC_SCRIPTDIR points to a non-existent directory.

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
src/dh-exec.c: Fix script detection

When iterating over scripts, check the correct return value for errors,
so if scandir() fails, we actually notice that, instead of crashing.

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
src/dh-exec.c: Cosmetic fix for some error messages

Some of the error messages were printed without a trailing newline, lets
address that.

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
src/dh-exec.c: Handle --help and unknown arguments separately

Instead of using -? for --help, use -h, and handle the two cases
differently.

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
t/test_help.bats: Two new tests

Add two new tests: one to test that specifying a non-executable script
produces an error, and another that a non-existent one does the same
too.

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
t/test_help.bats: New test case

Add a new test case to verify that dh-exec with an invalid helper
returns an error.

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
src/dh-exec-install.c: Return from the preamble

Instead of exiting directly from the preamble, return instead.

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
t/test_help.bats: New testcase

This one is mostly for the sake of coverage: unset DH_EXEC_*DIR so that
we get that part of the branch coverage too.

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
src/dh-exec.lib.c: Simplify dh_exec_ignore()

Since there's only one place we use dh_exec_ignore() from, and we always
pass a NULL there, we can simplify the function and remove the
parameter.

Also add a test case to verify that dh_exec_ignore() works.

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
t/test_help.bats: New test case

Test that running dh-exec-subst directly, with a non-existent scriptdir
produces an error.

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
t/: Rename test_help.bats to test_dh_exec.bats

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
src/dh-exec.lib.c: Simplify dh_exec_main()

argc can't ever be smaller than one, therefore there is no need to test
for that scenario.

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
t/: Add a few more tests

These tests are a bit of a hack, testing parts of the code not covered
by the other tests, by compiling a small helper program first.

For this to work, dh_exec_script_allowed() had to be made public.

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>