Skip to content
Open
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: 0 additions & 1 deletion src/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
/*.dat
*.sdf
.tmp/
.tmp\
*.bak
*.sbr
*.tlog
Expand Down
2 changes: 2 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,5 @@ function(mu_add_test)
endfunction()

add_subdirectory(text)

add_subdirectory(editor)
20 changes: 20 additions & 0 deletions tests/editor/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Editor-specific tests only.
# Shared test harness setup (doctest include, wine setup, mu_test_main,
# and mu_add_test) must remain in the top-level tests/CMakeLists.txt.

# Add Editor Leak Test (only runs when ENABLE_EDITOR is OFF)
if(NOT ENABLE_EDITOR)
# Generate a text file containing all sources of the Main target
file(GENERATE
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/main_sources.txt"
CONTENT "$<JOIN:$<TARGET_PROPERTY:Main,SOURCES>,\n>")

# Add a test that runs a Python script to verify MuEditor isn't in those sources
find_package(Python3 COMPONENTS Interpreter QUIET)
if(Python3_Interpreter_FOUND)
add_test(NAME test_editor_leak
COMMAND Python3::Interpreter ${CMAKE_CURRENT_SOURCE_DIR}/test_leak.py "${CMAKE_CURRENT_BINARY_DIR}/main_sources.txt")
else()
message(STATUS "Skipping test_editor_leak: Python3 interpreter not found")
endif()
endif()
28 changes: 28 additions & 0 deletions tests/editor/test_leak.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import sys

def main():
if len(sys.argv) < 2:
print("Usage: test_leak.py <sources_file>")
sys.exit(1)

sources_file = sys.argv[1]

with open(sources_file, 'r', encoding='utf-8') as f:
sources = f.read().splitlines()

# Normalise to forward slashes so the path-segment check is
# platform-independent and won't fire just because the repository
# happens to be cloned inside a directory called "MuEditor".
leaked_files = [s for s in sources if '/MuEditor/' in s.replace('\\', '/')]
Comment on lines +13 to +16

if leaked_files:
print("FAIL: MuEditor leaked into the build! The following editor files were found in the Main target sources:")
for f in leaked_files:
print(f" - {f}")
Comment on lines +10 to +21
sys.exit(1)
else:
print("PASS: No MuEditor files leaked into the build.")
sys.exit(0)

if __name__ == '__main__':
main()
Loading