Skip to content

Commit

Permalink
Test #570: Initial test case, but not working yet
Browse files Browse the repository at this point in the history
  • Loading branch information
curlybeast authored and jcar87 committed Nov 13, 2023
1 parent 782fe79 commit cf65462
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/resources/preserve_module_path/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
cmake_minimum_required(VERSION 3.24)
project(MyApp CXX)

list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/modules)

find_program(CCACHE ccache)
find_package(OpenSSL)
find_package(ZLIB)
find_package(prometheus-cpp)

include(CustomModule)
hello_world()

add_executable(app main.cpp)
target_link_libraries(app hello::hello bye::bye)
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

message(STATUS "Loaded custom module")

macro(hello_world)
message(WARNING "We should be seeing this warning, if we do the test works")
endmacro()
14 changes: 14 additions & 0 deletions tests/test_smoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,20 @@ def test_msvc_runtime_singleconfig(self, capfd, config, msvc_runtime):
expected_runtime_outputs = [f.format(expected_runtime=runtime) for f in expected_app_msvc_runtime]
assert all(expected in out for expected in expected_runtime_outputs)

class TestPreserveModulePath:
@pytest.fixture(scope="class", autouse=True)
def preserve_module_path_setup(self):
src_dir = Path(__file__).parent.parent
shutil.copytree(src_dir / 'tests' / 'resources' / 'preserve_module_path', ".", dirs_exist_ok=True)
yield

def test_preserve_module_path(self, capfd, chdir_build):
"Ensure that existing CMAKE_MODULE_PATH values remain in place after find_package(XXX) call"
run("cmake .. -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=conan_provider.cmake -DCMAKE_BUILD_TYPE=Release Module -DCMAKE_C_COMPILER=/usr/bin/cc", check=False)
out, _ = capfd.readouterr()
assert "We should be seeing this warning, if we do the test works" in out
run("cmake --build .")


class TestFindModules:
def test_find_module(self, capfd, basic_cmake_project):
Expand Down

0 comments on commit cf65462

Please sign in to comment.