Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

23 Commits

Folders and files

Repository files navigation

cmake_tests

Regression tests and example projects for the derammo/cmake submodule. Lives outside the cmake submodule so that:

  • consumers of the cmake submodule don't get test files in their tree
  • the submodule pins can be bumped here independently to test changes

Requirements

The tests in tests/ use only POSIX tools: sh, make, sed, find, grep. They check the files cmake/setup.make generates and the text of the cmake modules. The examples need the toolchains of the languages they build.

Running

After cloning:

git submodule update --init
make test

Each tests/test_*.sh file is a standalone script and can be run directly:

sh tests/test_root_sed_g_flag.sh

What is tested

The setup.make tests create an isolated sandbox under $TMPDIR, symlink the cmake submodule into it, run make -f .../cmake/setup.make <target>, and assert on the generated files. The others read the cmake modules directly.

Test Checks Passes when
test_root_sed_g_flag.sh setup.make root every REPLACE_PROJECT_NAME on a line is substituted, not just the first
test_library_local_sources.sh setup.make library every root-level source is listed in sources.cmake, not just the last
test_executable_local_sources.sh setup.make executable every root-level source is listed in sources.cmake, not just the last
test_executable_private_sources.sh setup.make executable every file under src/ is listed in sources.cmake, not just the last
test_generated_cmake_minimum_required.sh setup.make root, library, executable the generated root CMakeLists.txt declares cmake_minimum_required(VERSION 3.20) and the generated subdirectory files do not declare it
test_derammo_main_no_cmake_minimum_required.sh derammo_main.cmake the module does not call cmake_minimum_required
test_include_guards.sh every derammo_*.cmake each module calls include_guard()
test_maven_cd_quoted.sh derammo_maven.cmake no command changes into the build directory through an unquoted path

Examples

examples/ is one cmake project (examples/CMakeLists.txt, built with make from that directory) that exercises the cmake submodule pinned at examples/cmake against both languages:

Tree Generated by Contents
examples/cpp setup.make library / executable mylib (fixed source list), autolib (globbed sources), hello (executable), each library with a gtest/ suite
examples/typescript setup.make workspaces / typescript / npm an npm workspace root with mylib (TypeScript, vitest), jestlib (TypeScript, jest), tarball (TypeScript, vitest, npm pack tarball on build), and plain (no TypeScript, node built-in test runner)
examples/java hand written a maven hello world with a JUnit test; pom.xml is generated from pom.xml.in, and the root CMakeLists.txt points JDK at the system javac

Each npm package's package.json is generated from its _package_template.json at configure time; the packages differ only in which _package_template_*.json mixins they extend. make test from examples/ runs every registered test through ctest: the gtest suites, one npm run test per package, and mvn test; ctest --print-labels in the build directory lists the providers and make test-<label> runs one of them.

Updating the pins

The cmake submodule is pinned twice: at cmake, which the tests use, and at examples/cmake, which the examples build with. When a fix to the cmake submodule should be tested:

git -C cmake fetch
git -C cmake checkout <fixed commit>
git -C examples/cmake fetch
git -C examples/cmake checkout <fixed commit>
git add cmake examples/cmake
git commit -m "bump cmake to <sha>"
make test

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages