Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ProjectMacros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ macro(MAKE_SWIG_TARGET NAME SIMPLENAME KEY_I_FILE I_FILES PARENT_TARGET PARENT_S
)

target_compile_definitions(${swig_target} PRIVATE SHARED_OS_LIBS)
target_compile_definitions(${swig_target} PRIVATE SWIG_PYTHON_SILENT_MEMLEAK) # Shush it, cf #5421

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simple enough.

set_target_properties(${swig_target} PROPERTIES OUTPUT_NAME _${LOWER_NAME})
set_target_properties(${swig_target} PROPERTIES PREFIX "")
set_target_properties(${swig_target} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/python/")
Expand Down
8 changes: 8 additions & 0 deletions src/cli/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,14 @@ if(BUILD_TESTING)
PASS_REGULAR_EXPRESSION "Hello from -x, at .\\\\test_folder\\\\hello.xml"
)

add_test(NAME OpenStudioCLI.execute_python_script.no_memory_leak
COMMAND $<TARGET_FILE:openstudio> execute_python_script memleak_source.py
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/test/"
)
set_tests_properties(OpenStudioCLI.execute_python_script.no_memory_leak PROPERTIES
FAIL_REGULAR_EXPRESSION "swig/python detected a memory leak of type"
)
Comment on lines +510 to +516

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before:

1/1 Test #3901: OpenStudioCLI.execute_python_script.no_memory_leak ...***Failed Error regular expression found in output. Regex=[swig/python detected a memory leak of type] 2.12 sec


# ============ EndForward a Path properly no matter the slashes employed ============

# ============ Native Ruby Gems / Python Modules - C extensions =============
Expand Down
12 changes: 12 additions & 0 deletions src/cli/test/memleak_source.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import openstudio
import pytest

def openstudio_import():
m = openstudio.model.Model()
raise ValueError("Throwing on purpose")

def test_openstudio_import():
openstudio_import()

if __name__ == "__main__":
pytest.main([__file__, "--capture=no", "--verbose"])