CMake/Tests/RunCMake/CPack
Brad King af35ddc808 Tests: Add newline to RunCMake.CPack_RPM SOURCE_PACKAGE case
The `main.cpp` that this test generates needs a newline so that
compilers do not warn about a missing newline.  Otherwise the warning
causes RunCMake infrastructure to detect unexpected output.
2016-09-28 09:07:42 -04:00
..
DEB CPack/DEB: Add option to select archive type 2016-09-05 09:24:45 -04:00
RPM CPack/RPM debuginfo directories to sources 2016-09-27 08:18:21 -04:00
TGZ CPack: Add option to generate a checksum file next to each package file 2016-09-19 10:22:50 -04:00
CMakeLists.txt Tests: Add subtest support to RunCMake/CPack infrastructure 2016-09-19 10:20:13 -04:00
COMPONENTS_EMPTY_DIR.cmake CPack: allow packaging of empty directories 2015-09-29 01:18:18 +02:00
CPackTestHelpers.cmake Tests: Fix RunCMake.CPack test infrastructure after logical conflict 2016-09-20 16:05:41 -04:00
CUSTOM_NAMES.cmake CPack/Deb possibility to change package name 2016-05-23 19:55:46 +02:00
DEBUGINFO.cmake CPack/RPM debuginfo packages must contain sources 2016-09-27 08:18:21 -04:00
DEB_EXTRA.cmake CPack/Deb possibility to change package name 2016-05-23 19:55:46 +02:00
DEB_GENERATE_SHLIBS.cmake CPack/Deb possibility to change package name 2016-05-23 19:55:46 +02:00
DEB_GENERATE_SHLIBS_LDCONFIG.cmake CPack/Deb possibility to change package name 2016-05-23 19:55:46 +02:00
DEPENDENCIES.cmake Tests: Avoid OS X 10.5 limitation warning in RunCMake.CPack* tests 2015-10-01 09:47:41 -04:00
EMPTY_DIR.cmake CPack: allow packaging of empty directories 2015-09-29 01:18:18 +02:00
INSTALL_SCRIPTS.cmake CPack/RPM support for upper cased component variables 2016-02-13 02:09:32 +01:00
LONG_FILENAMES.cmake CPack/DEB: Add option to select archive type 2016-09-05 09:24:45 -04:00
MINIMAL.cmake
PACKAGE_CHECKSUM.cmake CPack: Add option to generate a checksum file next to each package file 2016-09-19 10:22:50 -04:00
PARTIALLY_RELOCATABLE_WARNING.cmake
PER_COMPONENT_FIELDS.cmake CPack: Added tests for package name and group controll fields 2015-12-07 20:15:49 +01:00
README.txt CPack/Deb test changes due to breaking changes 2016-05-13 10:46:05 -04:00
RPM_DIST.cmake CPack/RPM adding dist to release tag test 2016-05-14 20:21:32 +02:00
RunCMakeTest.cmake Merge topic 'cpack-rpm-srpm-package' 2016-09-20 08:40:55 -04:00
SOURCE_PACKAGE.cmake Tests: Add newline to RunCMake.CPack_RPM SOURCE_PACKAGE case 2016-09-28 09:07:42 -04:00
VerifyResult.cmake Merge topic 'cpack-rpm-srpm-package' 2016-09-20 08:40:55 -04:00

README.txt

RunCMake.CPack is a test module that is intended for testing of package
generators that can be validated from command line.

TODO: all tests should cover all packaging types (single package, grouped and
      component packaging)

-------------
Adding a test
-------------

CPack test root directory: 'Tests/RunCMake/CPack'.

All phases are executed separately for each generator that is bound to a test.
Tests for each generator are subtests of test 'RunCMake.CPack_<generator_name>'.

Each test must also be added to 'RunCMakeTest.cmake' script located in CPack
test root directory.
Line that adds a test is:
run_cpack_test(<test_name> "<generator_name>")

<generator_name> may be one generator e.g. "RPM" or multiple e.g. "RPM;DEB" and
will be run for all listed generators.

Test consists of
- test prerequirements phase (optional)
- CMake execution phase
- CPack execution phase
- verification of generated files

test prerequirements phase (optional):
--------------------------------------

In some cases individual tests for certain generator need additional
prerequirements met.

In such cases '<generator_name>/<test_name>-Prerequirements.cmake' file
containing 'function(get_test_prerequirements found_var)' should be created.
Function should return true if all prerequirements are met.

If prerequirements are not met test will be skipped outputting
'<test_name> - SKIPPED' string. Note that this doesn't fail the entire test
group.

TODO: skipped tests should provide expected error string so test should fail
      if error string is not found in the output of run test (this would add
      'EXPECTED FAIL' string on success and 'ERROR' on failure).

CMake execution phase:
----------------------

To add a new CPack test we first create a <test_name>.cmake script that contains
CMake commands that should be used as a preparation script for generation of
different types of packages. This script is placed into CPack test root
directory even if it will be used for only one of the generators.

If test will be used for multiple generators but some of them require some
generator specific commands then those commands should be added to a separate
file that should be located in '<generator_name>/<test_name>-specifics.cmake'
in CPack test root directory.

CPack execution phase:
----------------------

Only executes CPack for content that was generated during CMake execution
phase.

Verification of generated files:
--------------------------------

Verification of generated files consists of two phases
- mandatory verification phase
- optional verification phase

Mandatory verification phase checks that expected files were generated and
contain expected files.
Mandatory verification phase also checks that no other unexpected package files
were generated (this is executed even if EXPECTED_FILES_COUNT contains 0 in
order to verify that no files were generated).
CMake script '<generator_name>/<test_name>-ExpectedFiles.cmake' is required by
this step and must contain
- EXPECTED_FILES_COUNT variable that contains the number of expected files that
  will be generated (0 or more)
- EXPECTED_FILE_<file_number_starting_with_1> that contains globing expression
  that uniquely defines expected file name (will be used to find expected file)
  and should be present once for each expected file
- EXPECTED_FILE_CONTENT_<file_number_starting_with_1> that contains regular
  expression of files that should be present in generated file and should be
  present once for each expected file

Optional verification phase is generator specific and is optionaly executed.
This phase is executed if '<generator_name>/<test_name>-VerifyResult.cmake'
script exists.
In case that the script doesn't exist VerifyResult.cmake script automatically
prints out standard output and standard error from CPack execution phase that
is compared with '<generator_name>/<test_name>-stdout.txt' regular expression
and '<generator_name>/<test_name>-stderr.txt' regular expresson respectively.

----------------------
Adding a new generator
----------------------

To add a new generator we must
- add new generator directory (e.g. RPM for RPM generator) to CPack test root
  directory that contains 'Helpers.cmake' script. In this script a function
  named 'getPackageContent' must exist. This function should list files that
  are contained in a package. Function should accept two parameters
  + FILE variable that will contain path to file for which the content should be
    listed
  + RESULT_VAR that will tell the function which variable in parent scope should
    contain the result (list of files inside package file)
- add 'Prerequirements.cmake' script to generator directory. In this script a
  function named 'get_test_prerequirements' must exist. This function should
  set a variable in parent scope (name of the variable is the first parameter)
  that tells if prerequirements for test execution are met (certain programs,
  OS specifics, ...) and create a config file (name of the variable which
  contains file name and path is provided with the second parameter) that
  should contain 'set' commands for variables that will later be used in tests
  (e.g. location of dpkg program for DEB packages)
- add tests the same way as described above
- add generator to 'add_RunCMake_test_group' function call that is located in
  RunCMake CMakeLists.txt file