Skip to content

Commit bc9afdb

Browse files
authored
Test/modernize (#18292)
* modernize tests * speed up CMake checks * fixing tests * tests short summary * tests short summary * fix test
1 parent 079cd60 commit bc9afdb

31 files changed

+274
-292
lines changed

.github/actions/test-coverage/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ runs:
3030
if: ${{ inputs.tests }}
3131
shell: ${{ runner.os == 'Windows' && 'pwsh' || 'bash' }}
3232
run: |
33-
pytest ${{ inputs.tests }} --durations=${{ inputs.duration }} -n ${{ inputs.workers }} ${{ github.ref == 'refs/heads/develop2' && '--cov=conan --cov=conans --cov=test --cov-report=' || '' }}
33+
pytest ${{ inputs.tests }} -rf --durations=${{ inputs.duration }} -n ${{ inputs.workers }} ${{ github.ref == 'refs/heads/develop2' && '--cov=conan --cov=conans --cov=test --cov-report=' || '' }}
3434
3535
- name: Rename coverage file
3636
if: github.ref == 'refs/heads/develop2'

test/functional/command/runner_test.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,8 @@ def package(self):
605605
""")
606606

607607
cmakelist = textwrap.dedent("""
608+
set(CMAKE_CXX_COMPILER_WORKS 1)
609+
set(CMAKE_CXX_ABI_COMPILED 1)
608610
cmake_minimum_required(VERSION 3.15)
609611
project(pkg CXX)
610612
add_library(pkg src/hello.cpp)

test/functional/conftest.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,8 @@ def _matrix_c_interface_client():
224224
""")
225225
# Having here the config.cmake code to be able to manually check what CMake generates
226226
cmake = textwrap.dedent("""\
227+
set(CMAKE_CXX_COMPILER_WORKS 1)
228+
set(CMAKE_CXX_ABI_COMPILED 1)
227229
cmake_minimum_required(VERSION 3.15)
228230
project(matrix C CXX)
229231
add_library(matrix STATIC src/matrix.cpp)

test/functional/subsystems_build_test.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,8 @@ class TestSubsystemsCMakeBuild:
376376
377377
"""
378378
cmakelists = textwrap.dedent("""
379+
set(CMAKE_CXX_COMPILER_WORKS 1)
380+
set(CMAKE_CXX_ABI_COMPILED 1)
379381
cmake_minimum_required(VERSION 3.15)
380382
project(app CXX)
381383
message(STATUS "MYCMAKE VERSION=${CMAKE_VERSION}")

test/functional/toolchains/apple/test_xcodebuild_targets.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ def test(self):
8787
""")
8888

8989
cmakelists = textwrap.dedent("""
90+
set(CMAKE_CXX_COMPILER_WORKS 1)
91+
set(CMAKE_CXX_ABI_COMPILED 1)
9092
cmake_minimum_required(VERSION 3.15)
9193
project(PackageTest CXX)
9294

test/functional/toolchains/apple/test_xcodedeps_components.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ def test_xcodedeps_components():
4949
""")
5050

5151
cmakelists = textwrap.dedent("""
52+
set(CMAKE_CXX_COMPILER_WORKS 1)
53+
set(CMAKE_CXX_ABI_COMPILED 1)
5254
cmake_minimum_required(VERSION 3.15)
5355
project(myproject CXX)
5456
@@ -140,6 +142,8 @@ def package_info(self):
140142
"""
141143

142144
cmakelists_chat = textwrap.dedent("""
145+
set(CMAKE_CXX_COMPILER_WORKS 1)
146+
set(CMAKE_CXX_ABI_COMPILED 1)
143147
cmake_minimum_required(VERSION 3.15)
144148
project(chat CXX)
145149
find_package(network REQUIRED CONFIG)

test/functional/toolchains/cmake/cmakedeps/test_apple_frameworks.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def build(self):
4848
def test_apple_framework_xcode(client):
4949
app_cmakelists = textwrap.dedent("""
5050
cmake_minimum_required(VERSION 3.15)
51-
project(Testing CXX)
51+
project(Testing NONE)
5252
find_package(foolib REQUIRED)
5353
message(">>> foolib_FRAMEWORKS_FOUND_DEBUG: ${foolib_FRAMEWORKS_FOUND_DEBUG}")
5454
message(">>> foolib_FRAMEWORKS_FOUND_RELEASE: ${foolib_FRAMEWORKS_FOUND_RELEASE}")
@@ -91,6 +91,8 @@ def package_info(self):
9191
self.cpp_info.includedirs = []
9292
""")
9393
cmake = textwrap.dedent("""
94+
set(CMAKE_CXX_COMPILER_WORKS 1)
95+
set(CMAKE_CXX_ABI_COMPILED 1)
9496
cmake_minimum_required(VERSION 3.15)
9597
project(MyHello CXX)
9698
@@ -201,6 +203,8 @@ def test_apple_own_framework_cross_build(settings):
201203
client = TestClient()
202204

203205
test_cmake = textwrap.dedent("""
206+
set(CMAKE_CXX_COMPILER_WORKS 1)
207+
set(CMAKE_CXX_ABI_COMPILED 1)
204208
cmake_minimum_required(VERSION 3.15)
205209
project(Testing CXX)
206210
@@ -270,6 +274,8 @@ def test_apple_own_framework_cmake_deps():
270274
client = TestClient()
271275

272276
test_cmake = textwrap.dedent("""
277+
set(CMAKE_CXX_COMPILER_WORKS 1)
278+
set(CMAKE_CXX_ABI_COMPILED 1)
273279
cmake_minimum_required(VERSION 3.15)
274280
project(Testing CXX)
275281
message(STATUS "CMAKE_BINARY_DIR ${CMAKE_BINARY_DIR}")
@@ -346,6 +352,8 @@ def test_apple_own_framework_cmake_find_package_multi():
346352
client = TestClient()
347353

348354
test_cmake = textwrap.dedent("""
355+
set(CMAKE_CXX_COMPILER_WORKS 1)
356+
set(CMAKE_CXX_ABI_COMPILED 1)
349357
cmake_minimum_required(VERSION 3.15)
350358
project(Testing CXX)
351359
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin")
@@ -437,6 +445,8 @@ def package_info(self):
437445
void hello_api();
438446
""")
439447
cmakelists_txt = textwrap.dedent("""
448+
set(CMAKE_CXX_COMPILER_WORKS 1)
449+
set(CMAKE_CXX_ABI_COMPILED 1)
440450
cmake_minimum_required(VERSION 3.15)
441451
project(hello)
442452
include(GNUInstallDirs)
@@ -489,8 +499,10 @@ def test(self):
489499
}
490500
""")
491501
test_cmakelists_txt = textwrap.dedent("""
502+
set(CMAKE_CXX_COMPILER_WORKS 1)
503+
set(CMAKE_CXX_ABI_COMPILED 1)
492504
cmake_minimum_required(VERSION 3.15)
493-
project(test_package)
505+
project(test_package CXX)
494506
495507
find_package(HELLO REQUIRED CONFIG)
496508
@@ -532,6 +544,8 @@ def test_iphoneos_crossbuild():
532544
# at the toolchain (but it would require the toolchain to know about the deps)
533545
# https://stackoverflow.com/questions/65494246/cmakes-find-package-ignores-the-paths-option-when-building-for-ios#
534546
cmakelists = textwrap.dedent("""
547+
set(CMAKE_CXX_COMPILER_WORKS 1)
548+
set(CMAKE_CXX_ABI_COMPILED 1)
535549
cmake_minimum_required(VERSION 3.15)
536550
project(MyApp CXX)
537551
set(hello_DIR "${CMAKE_BINARY_DIR}")

test/functional/toolchains/cmake/cmakedeps/test_cmakedeps.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -445,8 +445,12 @@ def test_cpp_info_link_objects():
445445
object_cpp = gen_function_cpp(name="myobject")
446446
object_h = gen_function_h(name="myobject")
447447
cmakelists = textwrap.dedent("""
448+
set(CMAKE_CXX_COMPILER_WORKS 1)
449+
set(CMAKE_CXX_ABI_COMPILED 1)
450+
set(CMAKE_C_COMPILER_WORKS 1)
451+
set(CMAKE_C_ABI_COMPILED 1)
448452
cmake_minimum_required(VERSION 3.15)
449-
project(MyObject)
453+
project(MyObject C CXX)
450454
file(GLOB HEADERS *.h)
451455
add_library(myobject OBJECT myobject.cpp)
452456
if( WIN32 )
@@ -463,8 +467,10 @@ def test_cpp_info_link_objects():
463467

464468
test_package_cpp = gen_function_cpp(name="main", includes=["myobject"], calls=["myobject"])
465469
test_package_cmakelists = textwrap.dedent("""
470+
set(CMAKE_CXX_COMPILER_WORKS 1)
471+
set(CMAKE_CXX_ABI_COMPILED 1)
466472
cmake_minimum_required(VERSION 3.15)
467-
project(example)
473+
project(example CXX)
468474
find_package(myobject REQUIRED)
469475
add_executable(example example.cpp)
470476
target_link_libraries(example myobject::myobject)
@@ -566,8 +572,10 @@ def test_error_missing_build_type(matrix_client):
566572
""")
567573

568574
cmakelists = textwrap.dedent("""
575+
set(CMAKE_CXX_COMPILER_WORKS 1)
576+
set(CMAKE_CXX_ABI_COMPILED 1)
569577
cmake_minimum_required(VERSION 3.15)
570-
project(app)
578+
project(app CXX)
571579
find_package(matrix REQUIRED)
572580
add_executable(app)
573581
target_link_libraries(app matrix::matrix)
@@ -620,8 +628,10 @@ def test_map_imported_config(transitive_libraries):
620628
""")
621629

622630
cmakelists = textwrap.dedent("""
631+
set(CMAKE_CXX_COMPILER_WORKS 1)
632+
set(CMAKE_CXX_ABI_COMPILED 1)
623633
cmake_minimum_required(VERSION 3.15)
624-
project(app)
634+
project(app CXX)
625635
set(CMAKE_MAP_IMPORTED_CONFIG_DEBUG Release)
626636
find_package(engine REQUIRED)
627637
add_executable(app main.cpp)
@@ -658,6 +668,8 @@ def test_cmake_target_runtime_dlls(transitive_libraries):
658668

659669
client.run("new cmake_exe -d name=foo -d version=1.0 -d requires=engine/1.0 -f")
660670
cmakelists = textwrap.dedent("""
671+
set(CMAKE_CXX_COMPILER_WORKS 1)
672+
set(CMAKE_CXX_ABI_COMPILED 1)
661673
cmake_minimum_required(VERSION 3.15)
662674
project(foo CXX)
663675
find_package(engine CONFIG REQUIRED)

test/functional/toolchains/cmake/cmakedeps/test_cmakedeps_aliases.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def package_info(self):
3939

4040
cmakelists = textwrap.dedent("""
4141
cmake_minimum_required(VERSION 3.15)
42-
project(test)
42+
project(test NONE)
4343
4444
find_package(hello REQUIRED)
4545
get_target_property(link_libraries hello INTERFACE_LINK_LIBRARIES)
@@ -72,8 +72,8 @@ def package_info(self):
7272
""")
7373

7474
cmakelists = textwrap.dedent("""
75-
cmake_minimum_required(VERSION VERSION 3.15)
76-
project(test)
75+
cmake_minimum_required(VERSION 3.15)
76+
project(test NONE)
7777
7878
find_package(hello REQUIRED)
7979
get_target_property(link_libraries hola::adios INTERFACE_LINK_LIBRARIES)
@@ -107,7 +107,7 @@ def package_info(self):
107107

108108
cmakelists = textwrap.dedent("""
109109
cmake_minimum_required(VERSION 3.15)
110-
project(test)
110+
project(test NONE)
111111
112112
find_package(hello REQUIRED)
113113
get_target_property(link_libraries hello INTERFACE_LINK_LIBRARIES)
@@ -145,7 +145,7 @@ def package_info(self):
145145

146146
cmakelists = textwrap.dedent("""
147147
cmake_minimum_required(VERSION 3.15)
148-
project(test)
148+
project(test NONE)
149149
150150
find_package(hello REQUIRED)
151151
""")
@@ -180,7 +180,7 @@ def package_info(self):
180180

181181
cmakelists = textwrap.dedent("""
182182
cmake_minimum_required(VERSION 3.15)
183-
project(test)
183+
project(test NONE)
184184
185185
find_package(hello REQUIRED)
186186
""")

test/functional/toolchains/cmake/cmakedeps/test_cmakedeps_and_linker_flags.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ def package_info(self):
7676
"""
7777

7878
cmake = textwrap.dedent("""
79+
set(CMAKE_CXX_COMPILER_WORKS 1)
80+
set(CMAKE_CXX_ABI_COMPILED 1)
7981
cmake_minimum_required(VERSION 3.15)
8082
project(foo CXX)
8183
@@ -122,6 +124,8 @@ def build(self):
122124
123125
""")
124126
cmake = textwrap.dedent("""
127+
set(CMAKE_CXX_COMPILER_WORKS 1)
128+
set(CMAKE_CXX_ABI_COMPILED 1)
125129
cmake_minimum_required(VERSION 3.15)
126130
project(consumer CXX)
127131

0 commit comments

Comments
 (0)