Skip to content

Commit

Permalink
Unify and simplify c++ tests (#488)
Browse files Browse the repository at this point in the history
Unify and simplify c++ tests
  • Loading branch information
mattelser authored Oct 6, 2023
1 parent 0ffa9e7 commit 102f67d
Show file tree
Hide file tree
Showing 26 changed files with 113 additions and 261 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,6 @@ jobs:
if: matrix.config.name != 'CentOS 7 - GCC'
run: cmake --build build --config ${{ matrix.config.build-type }} --parallel ${{ steps.cpu-cores.outputs.count }}

- name: Tests
if: matrix.config.name != 'CentOS 7 - GCC'
run: ctest --test-dir build --output-on-failure

- name: Coverage
if: matrix.config.coverage == 'true'
run: cmake --build build --target generate-coverage --config ${{ matrix.config.build-type }}
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ exts/cesium.omniverse/certs/cacert.pem
_testoutput

# Test utils header has components generated by CMake
tests/testUtils.h
tests/include/testUtils.h

# Packman user files
*.user
Expand Down
14 changes: 7 additions & 7 deletions .vscode/launch.linux.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@
}
]
},
{
"name": "Python Debugging (attach)",
"type": "python",
"request": "attach",
"port": 3000,
"host": "localhost"
},
{
"name": "Tests Extension",
"preLaunchTask": "Build Only (debug)",
Expand Down Expand Up @@ -116,13 +123,6 @@
"loadAll": false,
"exceptionList": "libcesium.omniverse.plugin.so;libcesium.omniverse.cpp.tests.plugin.so"
}
},
{
"name": "Python Debugging (attach)",
"type": "python",
"request": "attach",
"port": 3000,
"host": "localhost"
}
]
}
14 changes: 7 additions & 7 deletions .vscode/launch.windows.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@
"type": "cppvsdbg",
"request": "launch"
},
{
"name": "Python Debugging (attach)",
"type": "python",
"request": "attach",
"port": 3000,
"host": "localhost"
},
{
"name": "Tests Extension",
"preLaunchTask": "Build Only (debug)",
Expand All @@ -44,13 +51,6 @@
"cwd": "${workspaceFolder}",
"type": "cppvsdbg",
"request": "launch"
},
{
"name": "Python Debugging (attach)",
"type": "python",
"request": "attach",
"port": 3000,
"host": "localhost"
}
]
}
15 changes: 1 addition & 14 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -156,19 +156,6 @@
"command": "python3 scripts/vscode_build.py clean ${input:build-type} ${input:compiler}"
}
},
{
"label": "Test",
"type": "shell",
"group": "build",
"problemMatcher": "$gcc",
"windows": {
"problemMatcher": "$msCompile",
"command": "scripts/vscode_build_launcher.bat test ${input:build-type} ${input:compiler}"
},
"linux": {
"command": "python3 scripts/vscode_build.py test ${input:build-type} ${input:compiler}"
}
},
{
"label": "Coverage",
"type": "shell",
Expand Down Expand Up @@ -248,4 +235,4 @@
}
}
]
}
}
7 changes: 2 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,7 @@ set(LINT_SOURCE_DIRECTORIES
"${PROJECT_SOURCE_DIR}/src/bindings"
"${PROJECT_SOURCE_DIR}/src/core"
"${PROJECT_SOURCE_DIR}/src/public"
"${PROJECT_SOURCE_DIR}/tests"
"${PROJECT_SOURCE_DIR}/cesiumOmniverseCppTestsExtension")
"${PROJECT_SOURCE_DIR}/tests")

# Source directories for coverage
set(COVERAGE_SOURCE_DIRECTORIES "${PROJECT_SOURCE_DIR}/include" "${PROJECT_SOURCE_DIR}/src")
Expand Down Expand Up @@ -325,7 +324,7 @@ if(CESIUM_OMNI_ENABLE_COVERAGE)
-DPROJECT_BUILD_DIRECTORY=${PROJECT_BINARY_DIR}
-DPROJECT_SOURCE_DIRECTORIES=${COVERAGE_SOURCE_DIRECTORIES_FORMATTED}
-DOUTPUT_DIRECTORY=${PROJECT_BINARY_DIR}/coverage -P ${PROJECT_SOURCE_DIR}/cmake/GenerateCoverage.cmake
DEPENDS $<TARGET_FILE:tests>
DEPENDS $<TARGET_FILE:cesium.omniverse.cpp.tests.plugin>
VERBATIM)
endif()

Expand Down Expand Up @@ -438,7 +437,6 @@ add_subdirectory(src)
if(CESIUM_OMNI_ENABLE_TESTS)
enable_testing()
add_subdirectory(tests)
add_subdirectory(cesiumOmniverseCppTestsExtension)
endif()

# Ninja and various Makefiles generators support generating compile_commands.json
Expand Down Expand Up @@ -669,7 +667,6 @@ install(
COMPONENT library
EXCLUDE_FROM_ALL)


if(CESIUM_OMNI_ENABLE_TESTS)
install(
TARGETS cesium.omniverse.cpp.tests.plugin
Expand Down
2 changes: 0 additions & 2 deletions cesiumOmniverseCppTestsExtension/CMakeLists.txt

This file was deleted.

3 changes: 0 additions & 3 deletions cesiumOmniverseCppTestsExtension/include/UsdUtilTests.h

This file was deleted.

103 changes: 0 additions & 103 deletions cesiumOmniverseCppTestsExtension/public/CesiumOmniverseCppTests.cpp

This file was deleted.

15 changes: 0 additions & 15 deletions cesiumOmniverseCppTestsExtension/public/UsdUtilTests.cpp

This file was deleted.

15 changes: 1 addition & 14 deletions docs/developer-setup/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -308,19 +308,7 @@ cmake --build build --config Release --parallel 8

## Unit Tests

```sh
cmake -B build
cmake --build build --target tests
ctest --test-dir build
```

Or run the doctest executable directly

```sh
cmake -B build
cmake --build build --target tests
./build/bin/tests
```
Unit tests can be run by starting the Cesium Omniverse Tests extension inside Omniverse.

## Coverage

Expand Down Expand Up @@ -506,7 +494,6 @@ Each workspace contains recommended extensions and settings for VSCode developme
- Build Only (debug) - builds the project in debug mode with the default compiler
- Build Only (release) - builds the project in release mode with the default compiler
- Clean - cleans the build directory
- Test - runs unit tests
- Coverage - generates a coverage report and opens a web browser showing the results
- Documentation - generates documentation and opens a web browser showing the results
- Format - formats the code with clang-format
Expand Down
16 changes: 0 additions & 16 deletions scripts/vscode_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,20 +139,6 @@ def build(args: Args):
process(install_kit_cmd)


def test(args: Args):
working_directory = os.getcwd()
bin_folder = get_bin_folder_name(args.build_type, args.compiler_name)
test_executable = "{}/{}/tests".format(working_directory, bin_folder)

configure_cmd = get_cmake_configure_command(args)
build_cmd = get_cmake_build_command(args, None)
test_cmd = [test_executable]

process(configure_cmd)
process(build_cmd)
process(test_cmd)


def coverage(args: Args):
if is_windows():
print("Coverage is not supported for Windows")
Expand Down Expand Up @@ -260,8 +246,6 @@ def main(av: List[str]):
build(args)
elif task == "clean":
clean(args)
elif task == "test":
test(args)
elif task == "coverage":
coverage(args)
elif task == "documentation":
Expand Down
38 changes: 3 additions & 35 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,35 +1,3 @@
include(Macros)

glob_files(SOURCES "${CMAKE_CURRENT_LIST_DIR}/*.cpp")

# replace a string in the utils header with the intended working dir for the test executable
set(TEST_WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}")
configure_file("${CMAKE_CURRENT_LIST_DIR}/testUtils.h.in" "${CMAKE_CURRENT_LIST_DIR}/testUtils.h")

# cmake-format: off
setup_app(
TARGET_NAME
tests
SOURCES
${SOURCES}
LIBRARIES
CesiumOmniverseCore
doctest::doctest
yaml-cpp::yaml-cpp
CXX_FLAGS
${CESIUM_OMNI_CXX_FLAGS}
CXX_FLAGS_DEBUG
${CESIUM_OMNI_CXX_FLAGS_DEBUG}
CXX_DEFINES
${CESIUM_OMNI_CXX_DEFINES}
CXX_DEFINES_DEBUG
${CESIUM_OMNI_CXX_DEFINES_DEBUG}
LINKER_FLAGS
${CESIUM_OMNI_LINKER_FLAGS}
LINKER_FLAGS_DEBUG
${CESIUM_OMNI_LINKER_FLAGS_DEBUG}
)
# cmake-format: on

# Discover tests for CTest (a.k.a make test)
doctest_discover_tests(tests ADD_LABELS 1)
add_subdirectory(bindings)
add_subdirectory(src)
add_subdirectory(include)
File renamed without changes.
File renamed without changes.
34 changes: 0 additions & 34 deletions tests/doctestMain.cpp

This file was deleted.

Loading

0 comments on commit 102f67d

Please sign in to comment.