Skip to content

Commit 2bc09e6

Browse files
committed
test: asciidoc golden tests
1 parent 1aca304 commit 2bc09e6

File tree

96 files changed

+21440
-110
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+21440
-110
lines changed

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
/local
88
/temp
99
/test-files/py
10-
/test-files/**/*.adoc
1110
/test-files/**/*.bad.xml
1211
docs/node_modules
1312
docs/build

CMakeLists.txt

+37-19
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ if (LLVM_ROOT)
8181
"No <LLVM_ROOT>/lib/cmake/llvm found.\n"
8282
"Please set LLVM_ROOT to the root of LLVM install.\n")
8383
endif()
84+
message(STATUS "LLVM_ROOT: ${LLVM_ROOT}")
8485
endif()
8586
if (Clang_ROOT)
8687
# Clang_ROOT is absolute
@@ -95,7 +96,19 @@ find_package(Clang REQUIRED CONFIG)
9596

9697
if (LLVM_ROOT)
9798
set(LIBCXX_DIR "${LLVM_ROOT}/include/c++/v1/")
99+
message(STATUS "LIBCXX_DIR: ${LIBCXX_DIR}")
100+
if (NOT EXISTS "${LIBCXX_DIR}")
101+
message(FATAL_ERROR
102+
"LIBCXX_DIR (${LIBCXX_DIR}) does not exist.\n"
103+
"LLVM_ROOT is set, but LIBCXX_DIR (/include/c++/v1) does not exist.\n")
104+
endif()
98105
set(STDLIB_INCLUDE_DIR "${LLVM_ROOT}/lib/clang/${Clang_VERSION_MAJOR}/include/")
106+
message(STATUS "STDLIB_INCLUDE_DIR: ${STDLIB_INCLUDE_DIR}")
107+
if (NOT EXISTS "${STDLIB_INCLUDE_DIR}")
108+
message(FATAL_ERROR
109+
"STDLIB_INCLUDE_DIR (${STDLIB_INCLUDE_DIR}) does not exist.\n"
110+
"LLVM_ROOT is set, but STDLIB_INCLUDE_DIR (/lib/clang/${Clang_VERSION_MAJOR}/include) does not exist.\n")
111+
endif()
99112
endif()
100113

101114
list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}")
@@ -337,29 +350,34 @@ if (MRDOCS_BUILD_TESTS)
337350
endif ()
338351
target_compile_definitions(mrdocs-test PRIVATE -DMRDOCS_TEST_FILES_DIR="${CMAKE_CURRENT_SOURCE_DIR}/test-files")
339352
add_test(NAME mrdocs-unit-tests COMMAND mrdocs-test --unit=true)
340-
add_test(NAME mrdocs-golden-tests
341-
COMMAND
342-
mrdocs-test
343-
--unit=false
344-
--action=test
345-
"${PROJECT_SOURCE_DIR}/test-files/golden-tests"
346-
--addons="${CMAKE_SOURCE_DIR}/share/mrdocs/addons"
347-
--system-includes="${LIBCXX_DIR}"
348-
--system-includes="${STDLIB_INCLUDE_DIR}")
349-
foreach (action IN ITEMS create update)
350-
add_custom_target(
351-
mrdocs-${action}-test-fixtures
353+
foreach (testgenerator IN ITEMS xml adoc)
354+
add_test(NAME mrdocs-golden-tests-${testgenerator}
352355
COMMAND
353356
mrdocs-test
354357
--unit=false
355-
--action=${action}
358+
--action=test
356359
"${PROJECT_SOURCE_DIR}/test-files/golden-tests"
357-
--addons="${CMAKE_SOURCE_DIR}/share/mrdocs/addons"
358-
--system-includes="${LIBCXX_DIR}"
359-
--system-includes="${STDLIB_INCLUDE_DIR}"
360-
DEPENDS mrdocs-test
360+
"--addons=${CMAKE_SOURCE_DIR}/share/mrdocs/addons"
361+
--generator=${testgenerator}
362+
"--stdlib-includes=${LIBCXX_DIR}"
363+
"--stdlib-includes=${STDLIB_INCLUDE_DIR}"
361364
)
362-
endforeach ()
365+
foreach (action IN ITEMS test create update)
366+
add_custom_target(
367+
mrdocs-${action}-test-fixtures-${testgenerator}
368+
COMMAND
369+
mrdocs-test
370+
--unit=false
371+
--action=${action}
372+
"${PROJECT_SOURCE_DIR}/test-files/golden-tests"
373+
"--addons=${CMAKE_SOURCE_DIR}/share/mrdocs/addons"
374+
--generator=${testgenerator}
375+
"--stdlib-includes=${LIBCXX_DIR}"
376+
"--stdlib-includes=${STDLIB_INCLUDE_DIR}"
377+
DEPENDS mrdocs-test
378+
)
379+
endforeach ()
380+
endforeach()
363381

364382
#-------------------------------------------------
365383
# XML lint
@@ -436,7 +454,7 @@ if (MRDOCS_BUILD_DOCS)
436454
COMMAND ${CMAKE_COMMAND} -E echo "Install npm dependencies"
437455
COMMAND ${NPM_EXECUTABLE} install
438456
COMMAND ${CMAKE_COMMAND} -E echo "Run Antora"
439-
COMMAND ${NPX_EXECUTABLE} antora local-antora-playbook.yml
457+
COMMAND ${NPX_EXECUTABLE} antora antora-playbook.yml
440458
WORKING_DIRECTORY ${DOCS_SOURCE_DIR}
441459
COMMENT "Generating MrDocs documentation"
442460
USES_TERMINAL

src/lib/Lib/ConfigOptions.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"name": "inputs",
1010
"command-line-only": true,
1111
"brief": "Configuration or compilation database files",
12-
"details": "The inputs are configuration files or compilation database files that are used to generate the documentation. These inputs can be configuration files or compilation database files. When the input ends with `mrdocs.yml`, it is interpreted as a configuration file, the file is read and the options are used to generate the documentation as if it was provided to the `config` option. When the input ends with `compilation_database.json` or `CMakeLists.txt`, it is interpreted as a compilation database file, the file is read and the compiler flags are used to generate the documentation as if it was provided to the `compilation-database` option.",
12+
"details": "The inputs are configuration files or compilation database files that used to generate the documentation. When the input ends with `mrdocs.yml`, it is interpreted as a configuration file, the file is read and the options are used to generate the documentation as if it was provided to the `config` option. When the input ends with `compilation_database.json` or `CMakeLists.txt`, it is interpreted as a compilation database file, the file is read and the compiler flags are used to generate the documentation as if it was provided to the `compilation-database` option.",
1313
"type": "list<path>",
1414
"default": [],
1515
"command-line-sink": true,

src/test/TestArgs.cpp

+10-9
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ R"(
5656
llvm::cl::init(test),
5757
llvm::cl::values(
5858
clEnumVal(test, "Compare output against expected."),
59-
clEnumVal(create, "Create missing expected xml files."),
60-
clEnumVal(update, "Update all expected xml files.")),
59+
clEnumVal(create, "Create missing expected documentation files."),
60+
clEnumVal(update, "Update all expected documentation files.")),
6161
llvm::cl::cat(commonCat))
6262

6363
, badOption(
@@ -76,20 +76,21 @@ R"(
7676
llvm::cl::desc("A list of directories and/or .cpp files to test."),
7777
llvm::cl::cat(commonCat))
7878

79+
, generator(
80+
"generator",
81+
llvm::cl::desc("The generator to use for tests."),
82+
llvm::cl::init("xml"))
83+
7984
, addons(
8085
"addons",
8186
llvm::cl::desc("The directory with the addons."),
8287
llvm::cl::cat(commonCat))
8388

84-
, systemIncludes(
85-
"system-includes",
86-
llvm::cl::desc("A list of paths to the system headers."),
89+
, stdlibIncludes(
90+
"stdlib-includes",
91+
llvm::cl::desc("A list of paths to std library headers."),
8792
llvm::cl::cat(commonCat))
8893

89-
, includes(
90-
"includes",
91-
llvm::cl::desc("A list of paths to additional include directories."),
92-
llvm::cl::cat(commonCat))
9394
{
9495
}
9596

src/test/TestArgs.hpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,11 @@ class TestArgs
4646
llvm::cl::opt<bool> badOption;
4747
llvm::cl::opt<bool> unitOption;
4848
llvm::cl::list<std::string> inputPaths;
49+
50+
// Options replication public settings
51+
llvm::cl::opt<std::string> generator;
4952
llvm::cl::opt<std::string> addons;
50-
llvm::cl::list<std::string> systemIncludes;
51-
llvm::cl::list<std::string> includes;
53+
llvm::cl::list<std::string> stdlibIncludes;
5254

5355
// Hide all options that don't belong to us
5456
void hideForeignOptions();

src/test/TestMain.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ void DoTestAction()
3232
{
3333
using namespace clang::mrdocs;
3434

35-
TestRunner runner;
35+
TestRunner runner(testArgs.generator);
3636
for(auto const& inputPath : testArgs.inputPaths)
3737
runner.checkPath(inputPath);
3838
auto const& results = runner.results;
@@ -55,9 +55,9 @@ void DoTestAction()
5555
os <<
5656
report::numberOf(results.numberOfDirs.load(),
5757
"directory", "directories") << " visited";
58-
if(auto n = results.expectedXmlMatching.load())
58+
if(auto n = results.expectedDocsMatching.load())
5959
os << ", " << report::numberOf(n, "file", "files") << " matched";
60-
if(auto n = results.expectedXmlWritten.load())
60+
if(auto n = results.expectedDocsWritten.load())
6161
os << ", " << report::numberOf(n, "file", "files") << " written";
6262
os << ".\n";
6363
report::print(os.str());

0 commit comments

Comments
 (0)