CMake/Tests/RunCMake/CPack
Brad King d3db070e9e Merge topic 'cpack-rpm-adding-dist-to-release-tag'
f5089cfc CPack/RPM adding dist to release tag test
f7003a60 CPack/RPM release dist tag support
2016-05-16 10:11:35 -04:00
..
DEB CPack/Deb test changes due to breaking changes 2016-05-13 10:46:05 -04:00
RPM Merge topic 'cpack-rpm-adding-dist-to-release-tag' 2016-05-16 10:11:35 -04:00
TGZ CPack: allow packaging of empty directories 2015-09-29 01:18:18 +02:00
CMakeLists.txt CPack: remove accidental changes 2015-09-23 09:15:57 -04:00
COMPONENTS_EMPTY_DIR.cmake CPack: allow packaging of empty directories 2015-09-29 01:18:18 +02:00
CPackTestHelpers.cmake CPack/Deb test changes due to breaking changes 2016-05-13 10:46:05 -04:00
DEB_EXTRA.cmake CPack/DEB: test preserve extra config file permissions 2015-09-17 15:30:39 -04:00
DEB_GENERATE_SHLIBS.cmake CPack/Deb test changes due to breaking changes 2016-05-13 10:46:05 -04:00
DEB_GENERATE_SHLIBS_LDCONFIG.cmake CPack/Deb test changes due to breaking changes 2016-05-13 10:46:05 -04: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
MINIMAL.cmake Tests: Add RunCMake tests for CPack{Deb,RPM} 2015-06-15 15:09:07 -04:00
PARTIALLY_RELOCATABLE_WARNING.cmake Tests: Move RunCMake.CPackRPM case into RunCMake.CPack_RPM test 2015-06-15 15:09:07 -04:00
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_CUSTOM_NAMES.cmake CPack/RPM different package names 2016-05-15 03:01:34 +02: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-adding-dist-to-release-tag' 2016-05-16 10:11:35 -04:00
VerifyResult.cmake Tests: Make RunCMake.CPack error messages more readable 2015-09-17 15:30:38 -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