Skip to content

Commit 5c9bc52

Browse files
committed
Add tests
1 parent dc13535 commit 5c9bc52

12 files changed

Lines changed: 126 additions & 12 deletions

File tree

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ jobs:
6363
run: |
6464
cmake --version
6565
cmake -S ./test -B ./build
66-
cmake --build ./build --config Release --verbose
66+
cmake --build ./build --config Release
6767
6868
- name: Run Tests
6969
working-directory: build

cmake/FindSphinx.cmake

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ if (Sphinx_FOUND AND NOT TARGET Sphinx::Build)
127127

128128
if (LIBRARY_PATH)
129129
if (CMAKE_SYSTEM_NAME STREQUAL Windows)
130-
list(JOIN LIBRARY_PATH ";" _LIBRARY_PATH_STRING)
130+
list(JOIN LIBRARY_PATH "\\;" _LIBRARY_PATH_STRING)
131131
else()
132132
list(JOIN LIBRARY_PATH ":" _LIBRARY_PATH_STRING)
133133
endif()
@@ -136,7 +136,7 @@ if (Sphinx_FOUND AND NOT TARGET Sphinx::Build)
136136

137137
if (PYTHON_PATH)
138138
if (CMAKE_SYSTEM_NAME STREQUAL Windows)
139-
list(JOIN PYTHON_PATH ";" _PYTHON_PATH_STRING)
139+
list(JOIN PYTHON_PATH "\\;" _PYTHON_PATH_STRING)
140140
else()
141141
list(JOIN PYTHON_PATH ":" _PYTHON_PATH_STRING)
142142
endif()
@@ -204,20 +204,12 @@ if (Sphinx_FOUND AND NOT TARGET Sphinx::Build)
204204

205205
list(APPEND _args ${_SOURCE_DIRECTORY} ${_OUTPUT_DIRECTORY})
206206

207-
message(STATUS "[sphinx_add_docs:${NAME}] SPHINX_EXECUTABLE='${SPHINX_EXECUTABLE}'")
208-
message(STATUS "[sphinx_add_docs:${NAME}] _env_args=${_env_args}")
209-
message(STATUS "[sphinx_add_docs:${NAME}] _args=${_args}")
210-
message(STATUS "[sphinx_add_docs:${NAME}] _WORKING_DIRECTORY='${_WORKING_DIRECTORY}'")
211-
message(STATUS "[sphinx_add_docs:${NAME}] _SOURCE_DIRECTORY='${_SOURCE_DIRECTORY}'")
212-
message(STATUS "[sphinx_add_docs:${NAME}] _OUTPUT_DIRECTORY='${_OUTPUT_DIRECTORY}'")
213-
214207
# Create target.
215208
add_custom_target(${NAME} ${_ALL} VERBATIM
216209
WORKING_DIRECTORY ${_WORKING_DIRECTORY}
217210
COMMENT ${_COMMENT}
218211
DEPENDS ${_DEPENDS}
219212
COMMAND ${CMAKE_COMMAND} -E make_directory ${_OUTPUT_DIRECTORY}
220-
COMMAND ${CMAKE_COMMAND} -E env ${_env_args} "${SPHINX_EXECUTABLE}" ${_args}
221-
COMMAND_EXPAND_LISTS)
213+
COMMAND ${CMAKE_COMMAND} -E env ${_env_args} "${SPHINX_EXECUTABLE}" ${_args})
222214
endfunction()
223215
endif()
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
if(WIN32)
2+
set(EXPECTED "\\path1;\\path2;\\path3")
3+
else()
4+
set(EXPECTED "/path1:/path2:/path3")
5+
endif()
6+
configure_file(index.html index.html @ONLY)
7+
8+
# NOTE: configure_file() adds a trailing newline; Sphinx doesn’t.
9+
# Strip it so compare_files remains stable.
10+
file(READ ${CMAKE_CURRENT_BINARY_DIR}/index.html _content)
11+
string(REGEX REPLACE "\n$" "" _content "${_content}")
12+
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/index.html "${_content}")
13+
14+
sphinx_add_docs(doc8 ALL
15+
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
16+
LIBRARY_PATH_PREPEND "/path1" "/path2" "/path3")
17+
18+
add_test(NAME LibraryPathPrepend
19+
COMMAND ${CMAKE_COMMAND} -E compare_files
20+
${CMAKE_CURRENT_BINARY_DIR}/index.html
21+
${CMAKE_CURRENT_BINARY_DIR}/doc/index.html)

test/08-library-path/conf.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import sys
2+
from pathlib import Path
3+
4+
root = Path(__file__).resolve().parent
5+
sys.path.insert(0, str((root/ "../resources/_extensions").resolve()))
6+
7+
project = "foo"
8+
copyright = "2026, john-doe"
9+
extensions = ["sphinx_env"]
10+
templates_path = ["../resources/_templates"]
11+
html_permalinks = False

test/08-library-path/index.html

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>foo</title>
6+
</head>
7+
<body>
8+
<header>
9+
<h1>foo</h1>
10+
</header>
11+
<main>
12+
<p>@EXPECTED@</p>
13+
14+
</main>
15+
<footer>
16+
<p>&copy2026, john-doe</p>
17+
</footer>
18+
</body>
19+
</html>

test/08-library-path/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.. env:: LIBRARY_PATH 3

test/09-python-path/CMakeLists.txt

Whitespace-only changes.

test/09-python-path/conf.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import sys
2+
from pathlib import Path
3+
4+
root = Path(__file__).resolve().parent
5+
sys.path.insert(0, str((root/ "../resources/_extensions").resolve()))
6+
7+
project = "foo"
8+
copyright = "2026, john-doe"
9+
extensions = ["sphinx_env"]
10+
templates_path = ["../resources/_templates"]
11+
html_permalinks = False

test/10-environment/CMakeLists.txt

Whitespace-only changes.

test/10-environment/conf.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import sys
2+
from pathlib import Path
3+
4+
root = Path(__file__).resolve().parent
5+
sys.path.insert(0, str((root/ "../resources/_extensions").resolve()))
6+
7+
project = "foo"
8+
copyright = "2026, john-doe"
9+
extensions = ["sphinx_env"]
10+
templates_path = ["../resources/_templates"]
11+
html_permalinks = False

0 commit comments

Comments
 (0)