#+TITLE: Integration Tests for dh-make-elpa
#+AUTHOR: Xiyue Deng <manphiz@gmail.com>

This document describes the structure of the integration tests and
usages.

* How do the Tests Work?

The tests basically create a repository based on each test case, run
`dh-make-elpa' under it, and compare the generated files with the
expected files.

It runs in two modes: build-time and autopkgtest.  The build-time mode
uses the `dh-make-elpa' in the source tree, while autopkgtest uses the
`dh-make-elpa' from the installed packages.  The default is the
autopkgtest mode.  The build-time mode is enabled by the
"--build_time_test" option.

* File System Structure

The file system structure under the test directory is like below:

#+BEGIN_EXAMPLE
t
├── README.org
├── data
│   ├── github_team
│   │   ├── expected
│   │   └── repo
│   ├── simple
│   │   ├── expected
│   │   └── repo
│   └── simple_team
│       ├── expected
│       └── repo
│
│   ...
│
├── lib
│   └── TestHelper.pm
└── test_all_data.t
#+END_EXAMPLE

The directories under `t/data' are the test cases, each contains a
`repo' directory that holds the source repo where one can run
`dh-make-elpa', and a `expected' directory that stores the output
`debian/' directory.  The test utility will create a temporary
directory to perform the check to avoid cluttering up the source.

`dh-make-elpa' also supports `--pkg-emacsen'.  If a test case name
ends with `_team' (like `github_team' in the example above), the test
will pass `--pkg-emacsen' when running `dh-make-elpa'.

* Update the expected output

To make it easier to update the contents of the `expected' directory -
either for fixing mistakes or updating the code changes the generated
files as expected - one can use `t/utils/check_diff_in_test_cases'. By
default it will just output any diff found in each test cases, and
when passing `--update' it will change the contents of the `expected'
directory with the generated files using the latest `dh-make-elpa' in
the source tree. One should carefully compare the changes (diff)
before committing the changes.
