Skip to content

Commit

Permalink
Tests extension now waits for stage to open before running
Browse files Browse the repository at this point in the history
  • Loading branch information
mattelser committed Oct 4, 2023
1 parent bc50052 commit 3f5693c
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 6 deletions.
28 changes: 27 additions & 1 deletion .vscode/launch.linux.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,32 @@
}
]
},
{
"name": "Tests Extension",
"preLaunchTask": "Build Only (debug)",
"program": "${workspaceFolder}/extern/nvidia/_build/target-deps/kit-sdk/kit",
"args": [
"${workspaceFolder}/apps/cesium.omniverse.cpp.tests.runner.kit"
],
"env": {
// Disable LSAN when debugging since it doesn't work with GDB and prints harmless but annoying warning messages
"ASAN_OPTIONS": "detect_leaks=0",
"UBSAN_OPTIONS": "print_stacktrace=1"
},
"cwd": "${workspaceFolder}",
"type": "cppdbg",
"request": "launch",
"MIMode": "gdb",
"setupCommands": [
{
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"text": "set print elements 0"
}
]
},
{
"name": "Python Debugging (attach)",
"type": "python",
Expand All @@ -95,4 +121,4 @@
"host": "localhost"
}
]
}
}
13 changes: 12 additions & 1 deletion .vscode/launch.windows.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,17 @@
"type": "cppvsdbg",
"request": "launch"
},
{
"name": "Tests Extension",
"preLaunchTask": "Build Only (debug)",
"program": "${workspaceFolder}/extern/nvidia/_build/target-deps/kit-sdk/kit.exe",
"args": [
"${workspaceFolder}/apps/cesium.omniverse.cpp.tests.runner.kit"
],
"cwd": "${workspaceFolder}",
"type": "cppvsdbg",
"request": "launch",
},
{
"name": "Python Debugging (attach)",
"type": "python",
Expand All @@ -42,4 +53,4 @@
"host": "localhost"
}
]
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import os
import carb.events
import omni.ext
import omni.usd
import omni.kit.ui
import omni.kit.app
from .bindings import acquire_cesium_omniverse_tests_interface, release_cesium_omniverse_tests_interface


Expand All @@ -16,15 +18,27 @@ def on_startup(self):
tests_interface = acquire_cesium_omniverse_tests_interface()

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()
update_stream = omni.kit.app.get_app().get_update_event_stream()

tests_interface.run_all_tests(stageId)
# To ensure the tests only run after the stage has been opened, we
# attach a handler to an event that occurs every frame. That handler
# checks if the stage has opened, runs once, then detaches itself
self._run_once_sub = update_stream.create_subscription_to_pop(
self.run_once_after_stage_opens, name="Run once after stage opens"
)

print("Started Cesium Tests Extension.")

def run_once_after_stage_opens(self, carb_event: carb.events.IEvent):
print(f"update: {carb_event.payload['dt']}")
if omni.usd.get_context().get_stage_state() == omni.usd.StageState.OPENED:
print("Beginning Cesium Tests Extension tests")
stageId = omni.usd.get_context().get_stage_id()
tests_interface.run_all_tests(stageId)
print("Cesium Tests Extension tests complete")
self._run_once_sub.unsubscribe()

def on_shutdown(self):
print("Stopping Cesium Tests Extension...")
release_cesium_omniverse_tests_interface(tests_interface)
Expand Down

0 comments on commit 3f5693c

Please sign in to comment.