mirror of
https://github.com/cpm-cmake/CPM.cmake.git
synced 2025-11-17 14:47:30 -05:00
* Initial commit for integration tests. Experimental. Playing with potential syntax
* Some experimental code to setup tests
* Piecewise building of CMakeLists
* First check
* Alternative approach. Using ruby's test/unit
* Parse CMakeCache. Separate lib
* First integration test
* Latest Format.cmake. Passing style
* Allow user-provided integration test dir. Allow reuse
* Separate class with utils for cache (no longer pure Hash)
* Allow running of tests from any dir
* Add integration tests to CI
* Use an in-source integration test directory
* Allow relative integration test dir from env
* Custom assertion for a success of CommandResult
* Windows-latest-latest
* Enrich CMakeCache class with more CPM data
* Added test for CPM-specific CMakeCache values
* Style
* Style
* test_update_single_package
* WiP for source cache test
* Small source_cache test
* Style
* Moved env clean to cleanup to make setup methods simpler (not require super)
* WiP for integration test documentation
* WiP for integration test documentation
* Project file creation tweaks
* Split docs into multiple files. Complete tutorial. Reference.
* Tips
* Typo
* Setup Ruby inistead of requiring windows-2022
* Revert "Setup Ruby inistead of requiring windows-2022"
This reverts commit 8aa2732145.
4.0 KiB
4.0 KiB
Integration Test Framework Refernce
TestLib
A module for the framework. Provides global data and functionality. For ease of use the utility classes are not in this module.
Provides:
TMP_DIR- the temporary directory for the current test runCPM_PATH- path to CPM.cmake. The thing that is being testedTEMPLATES_DIR- path to integration test templatesCPM_ENV- an array of the names of all environment variables, which CPM.cmake may read.clear_env- a function to clear all aforementioned environment variables
Project
A helper class to manage a CMake project.
Provides:
#initialize(src_dir, bin_dir)- create a project with a given source and binary directory#src_dir,#bin_dir- get project directories#create_file(target_path, text, args = {})- create a file in the project's source directory with a given test. Theargshash is used to interpolate markup in the text string.- Will set
:cpm_pathinargstoTestLib::CPM_PATHif not already present. - If
:packageis present it will be added to the array:packages - Will convert
:packagesform an array to a string
- Will set
#create_file_from_template(target_path, source_path, args = {})- create a file in the project source directory, based on another file in the project source directory. The contents of the file atsource_pathwill be read and used increate_file#create_lists_from_default_template(args = {})- same ascreate_file_from_template('CMakeLists.txt', 'lists.in.cmake', args)::CommandResult- a struct of:out- the standard output from a command executionerr- the standard error output from the executionstatus- theProcess::Statusof the execution
#configure(extra_args = '') => CommandResult- configure the project with optional extra args to CMake#build(extra_args = '') => CommandResult- build the project with optional extra args to CMake::CMakeCache- a helper class with the contents of a CMakeCache.txt. Provides:::Entry- a CMake cache entry of:val- the value as stringtype- the type as stringadvanced?- whether the entry is an advanced optiondesc- the description of the entry (can be an empty string)
::Package- the CMake cache for a CPM.cmake package. A struct of:ver- the version as stringsrc_dir,bin_dir- the source and binary directories of the package
.from_dir(dir)- create an instance ofCMakeCachefrom<dir>/CMakeLists.txt#initialize(entries)- create a cache from a hash of entries by name. Will populate packages.#entries => {String => Entry}- the entries of the cache#packages => {String => Package}- CPM.cmake packages by name found in the cache#[](key) => String- an entry value from an entry name. Created because the value is expected to be needed much more frequently than the entire entry data. To get a full entry usecache.entries['name'].
read_cache => CMakeCache- reads the CMake cache in the binary directory of the project and returns it as aCMakeCacheinstance
IntegrationTest
The class which must be a parent of all integration test case classes. It itself extends Test::Unit::TestCase with:
Assertions
assert_success(res)- assert that an instance ofProject::CommandResultis a successassert_same_path(a, b)- assert that two strings represent the same path. For example on Windowsc:\fooandC:\Foodo.
Utils
cur_test_dir- the directory of the current test case. A subdirectory ofTestLib::TMP_DIRmake_project(template_dir = nil)- create a project from a test method. Will create a the project's source and binary directories as subdirectories ofcur_test_dir.- Optionally work with a template directory, in which case it will copy the contents of the template directory (one from
templates) in the project's source directory.
- Optionally work with a template directory, in which case it will copy the contents of the template directory (one from