From bc50052be45319fe61d8cfbbb049daea59944abf Mon Sep 17 00:00:00 2001 From: elser Date: Tue, 3 Oct 2023 10:44:18 -0400 Subject: [PATCH] tests extension crashes when loading unless kit 105.1 update is reverted --- .../include/UsdUtilTests.h | 3 +++ .../public/CesiumOmniverseCppTests.cpp | 8 ++++++-- .../public/UsdUtilTests.cpp | 20 +++++++++++++++++++ .../cesium/omniverse/cpp/tests/extension.py | 4 +++- 4 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 cesiumOmniverseCppTestsExtension/include/UsdUtilTests.h create mode 100644 cesiumOmniverseCppTestsExtension/public/UsdUtilTests.cpp diff --git a/cesiumOmniverseCppTestsExtension/include/UsdUtilTests.h b/cesiumOmniverseCppTestsExtension/include/UsdUtilTests.h new file mode 100644 index 000000000..75fd14a59 --- /dev/null +++ b/cesiumOmniverseCppTestsExtension/include/UsdUtilTests.h @@ -0,0 +1,3 @@ +#pragma once + +void run_all_UsdUtil_tests(); diff --git a/cesiumOmniverseCppTestsExtension/public/CesiumOmniverseCppTests.cpp b/cesiumOmniverseCppTestsExtension/public/CesiumOmniverseCppTests.cpp index cee68259c..383d5a143 100644 --- a/cesiumOmniverseCppTestsExtension/public/CesiumOmniverseCppTests.cpp +++ b/cesiumOmniverseCppTestsExtension/public/CesiumOmniverseCppTests.cpp @@ -5,9 +5,10 @@ #include "CesiumOmniverseCppTests.h" +#include "UsdUtilTests.h" + #include "cesium/omniverse/Context.h" #include "cesium/omniverse/LoggerSink.h" -#include "cesium/omniverse/UsdUtil.h" #include #include @@ -66,7 +67,9 @@ class CesiumOmniverseCppTestsPlugin final : public ICesiumOmniverseCppTestsInter CESIUM_LOG_INFO("Running Cesium Omniverse Tests with stage id: {}", stage_id); - // construct a context + Context::instance().setStageId(stage_id); + + // construct a doctest context doctest::Context context; // sets the context as the default one - so asserts used outside of a testing context do not crash @@ -77,6 +80,7 @@ class CesiumOmniverseCppTestsPlugin final : public ICesiumOmniverseCppTestsInter context.setAssertHandler(handler); exampleTest(); + run_all_UsdUtil_tests(); CESIUM_LOG_INFO("Cesium Omniverse Tests complete"); } diff --git a/cesiumOmniverseCppTestsExtension/public/UsdUtilTests.cpp b/cesiumOmniverseCppTestsExtension/public/UsdUtilTests.cpp new file mode 100644 index 000000000..da3d2fa7f --- /dev/null +++ b/cesiumOmniverseCppTestsExtension/public/UsdUtilTests.cpp @@ -0,0 +1,20 @@ +// #define DOCTEST_CONFIG_IMPLEMENT +// #define DOCTEST_CONFIG_IMPLEMENTATION_IN_DLL +// #define DOCTEST_CONFIG_SUPER_FAST_ASSERTS + +#include "UsdUtilTests.h" + +#include "cesium/omniverse/Context.h" +#include "cesium/omniverse/LoggerSink.h" +#include "cesium/omniverse/UsdUtil.h" + +#include + +#include + +void run_all_UsdUtil_tests() { + using namespace cesium::omniverse; + CESIUM_LOG_INFO("Running UsdUtil Tests..."); + CHECK(cesium::omniverse::UsdUtil::primExists(pxr::SdfPath("/Cesium"))); + CESIUM_LOG_INFO("UsdUtil Tests complete!"); +} diff --git a/exts/cesium.omniverse.cpp.tests/cesium/omniverse/cpp/tests/extension.py b/exts/cesium.omniverse.cpp.tests/cesium/omniverse/cpp/tests/extension.py index 4d1538311..13f6d0ab2 100644 --- a/exts/cesium.omniverse.cpp.tests/cesium/omniverse/cpp/tests/extension.py +++ b/exts/cesium.omniverse.cpp.tests/cesium/omniverse/cpp/tests/extension.py @@ -1,3 +1,4 @@ +import os import omni.ext import omni.usd import omni.kit.ui @@ -14,7 +15,8 @@ def on_startup(self): global tests_interface tests_interface = acquire_cesium_omniverse_tests_interface() - tests_interface.on_startup("exts/cesium.omniverse") + tests_interface.on_startup(os.path.join(os.path.dirname(__file__), "../../../../../cesium.omniverse")) + # tests_interface.on_startup("/home/melser/git/cesium-omniverse/exts/cesium.omniverse/cesium/omniverse/../../") # TODO ensure the stage has been set up before getting stage id stageId = omni.usd.get_context().get_stage_id()