mirror of
https://github.com/cpm-cmake/CPM.cmake.git
synced 2025-11-18 07:07:47 -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.
92 lines
3.0 KiB
Ruby
92 lines
3.0 KiB
Ruby
require_relative './lib'
|
|
|
|
class Simple < IntegrationTest
|
|
ADDER_PACKAGE_NAME = 'testpack-adder'
|
|
|
|
def test_update_single_package
|
|
prj = make_project 'using-adder'
|
|
adder_cache0 = nil
|
|
adder_ver_file = nil
|
|
|
|
create_with_commit_sha = -> {
|
|
prj.create_lists_from_default_template package:
|
|
'CPMAddPackage("gh:cpm-cmake/testpack-adder#cad1cd4b4cdf957c5b59e30bc9a1dd200dbfc716")'
|
|
assert_success prj.configure
|
|
|
|
cache = prj.read_cache
|
|
assert_equal 1, cache.packages.size
|
|
|
|
adder_cache = cache.packages[ADDER_PACKAGE_NAME]
|
|
assert_not_nil adder_cache
|
|
assert_equal '0', adder_cache.ver
|
|
assert File.directory? adder_cache.src_dir
|
|
assert File.directory? adder_cache.bin_dir
|
|
|
|
adder_ver_file = File.join(adder_cache.src_dir, 'version')
|
|
assert File.file? adder_ver_file
|
|
assert_equal 'initial', File.read(adder_ver_file).strip
|
|
|
|
# calculated adder values
|
|
assert_equal 'ON', cache['ADDER_BUILD_EXAMPLES']
|
|
assert_equal 'ON', cache['ADDER_BUILD_TESTS']
|
|
assert_equal adder_cache.src_dir, cache['adder_SOURCE_DIR']
|
|
assert_equal adder_cache.bin_dir, cache['adder_BINARY_DIR']
|
|
|
|
# store for future comparisons
|
|
adder_cache0 = adder_cache
|
|
}
|
|
update_to_version_1 = -> {
|
|
prj.create_lists_from_default_template package:
|
|
'CPMAddPackage("gh:cpm-cmake/testpack-adder@1.0.0")'
|
|
assert_success prj.configure
|
|
|
|
cache = prj.read_cache
|
|
assert_equal 1, cache.packages.size
|
|
|
|
adder_cache = cache.packages[ADDER_PACKAGE_NAME]
|
|
assert_not_nil adder_cache
|
|
assert_equal '1.0.0', adder_cache.ver
|
|
|
|
# dirs shouldn't have changed
|
|
assert_equal adder_cache0.src_dir, adder_cache.src_dir
|
|
assert_equal adder_cache0.bin_dir, adder_cache.bin_dir
|
|
|
|
assert_equal '1.0.0', File.read(adder_ver_file).strip
|
|
}
|
|
update_with_option_off_and_build = -> {
|
|
prj.create_lists_from_default_template package: <<~PACK
|
|
CPMAddPackage(
|
|
NAME testpack-adder
|
|
GITHUB_REPOSITORY cpm-cmake/testpack-adder
|
|
VERSION 1.0.0
|
|
OPTIONS "ADDER_BUILD_TESTS OFF"
|
|
)
|
|
PACK
|
|
assert_success prj.configure
|
|
assert_success prj.build
|
|
|
|
exe_dir = File.join(prj.bin_dir, 'bin')
|
|
assert File.directory? exe_dir
|
|
|
|
exes = Dir[exe_dir + '/**/*'].filter {
|
|
# on multi-configuration generators (like Visual Studio) the executables will be in bin/<Config>
|
|
# also filter-out other articacts like .pdb or .dsym
|
|
!File.directory?(_1) && File.stat(_1).executable?
|
|
}.map {
|
|
# remove .exe extension if any (there will be one on Windows)
|
|
File.basename(_1, '.exe')
|
|
}.sort
|
|
|
|
# we should end up with two executables
|
|
# * simple - the simple example from adder
|
|
# * using-adder - for this project
|
|
# ...and notably no test for adder, which must be disabled from the option override from above
|
|
assert_equal ['simple', 'using-adder'], exes
|
|
}
|
|
|
|
create_with_commit_sha.()
|
|
update_to_version_1.()
|
|
update_with_option_off_and_build.()
|
|
end
|
|
end
|