---
name: "Test::Lintian::Harness"
section: "3"
platform: "linux"
package: "lintian"
version: "2.5.50.4"
release: "Debian 9 (Stretch)"
platforms: ["linux"]
url: "https://new.carta.tech/Test::Lintian::Harness"
---

# Test::Lintian::Harness(3)

## NAME

Test::Lintian::Harness -- Helper tools for t/runtests

## SYNOPSIS

```
  use Test::Lintian::Harness qw(up_to_date);
  if (not up_to_date('some/build-stamp', 'some/dir')) {
    # do rebuild
  }
```

## DESCRIPTION

Helper functions for t/runtests.

## FUNCTIONS

- skip\_reaon(SKIP\_FILE)

  Return the (human-readable) reason for skipping a test by reading the SKIP\_FILE.

- copy\_template\_dir(SKEL\_DIR, TEST\_SRC\_DIR, TEST\_TARGET\_DIR, \[EXCL\_SKEL\[, EXCL\_SRC\]\])

  Populate TEST\_TARGET\_DIR with files/dirs from SKEL\_DIR and TEST\_SRC\_DIR.  If given, EXCL\_SKEL and EXCL\_SRC must be a listref containing rsync "--exclude" options.

- runsystem(CMD...)

  Run CMD via system, but throw an error if CMD does not return 0.

- runsystem\_ok(CMD...)

  Run CMD via system, but throw an error if CMD does not return 0 or 1.

  Returns 1 if CMD returned successfully (i.e. 0), otherwise 0.

  This is mostly useful for running Lintian, which may return 0 or 1 on "success".

- up\_to\_date(STAMPFILE, DIR\[, RUNNER\_TS\])

  Returns true if the mtime of STAMPFILE is greater than or equal to the mtime of all files in DIR.  If RUNNER\_TS is given, then the mtime of STAMPFILE must also be greater than or equal to the value of RUNNER\_TS.

  If STAMPFILE does not exist, this function returns false unconditionally.

- check\_test\_depends(TESTDATA)

  Given a TESTDATA with a dependency requirement, check whether the dependency requirement is satisfied.  If satisfied, return `"undef"`, otherwise return a (human-readable) string containing the missing dependencies.

- read\_test\_desc(FILENAME)

  Parse FILENAME as a test description file, do a quick validation of its contents and return it in a hashref.  This is similar get\_dsc\_control (DSCFILE) except for the extra validation.

- fill\_in\_tmpl(FILE, DATA)

  Create FILE using "${FILE}.in" as a template and DATA as template data.

- chdir\_runcmd(DIR, CMD\_REF\[, LOG\_FILE\])

  Fork, chdir to DIR and exec the command (plus arguments) contained in CMD\_REF.  The child process's STDERR is merged into its STDOUT.  The STDOUT stream of the child process is either directed to the path denoted by LOG\_FILE (if given and not `"undef"`) or to */dev/null*.

  Returns 0 on success and non-zero otherwise.

- is\_tag\_in\_file(TAGNAME, FILENAME)

  Returns true if FILENAME appears to be output from Lintian, which emitted TAGNAME from that run.

- find\_tests\_for\_tag(TAGNAME, GLOB\_EXPR)

  Find checks for the Lintian tag denoted by TAGNAME that match the GLOB\_EXPR. Note that GLOB\_EXPR must match only the "desc" file of the tests.

  This function returns a list of the test-data for each of these tests.

- generic\_find\_test\_for\_tag(TAGNAME, GLOB\_EXPR\[, TCODE\])

  Looks for TAGNAME in all files returned by using glob on GLOB\_EXPR. TCODE is called for each file with TAGNAME as first argument and the filename as second argument.  TCODE is expected to return a truth value that if the test should be run.  If TCODE returns something that is not just a raw truth value (e.g. a hash ref), this will be taken as the "test", otherwise this sub will attempt to guess the test name from the file.

  If TCODE is omitted, "is\_tag\_in\_file(TAGNAME, FILENAME)" will be used.

  Returns a list of values returned by TCODE or guessed test names (as per above)
