From c340c14cf248ffae4424832b9d5227d1258df1cc Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Sat, 21 Jul 2018 14:10:54 -0400 Subject: [PATCH 1/2] tests: Improve the CMakeLists.txt * Add a FOLLOW_SYMLINKS so Awesome 3rd party module can share the awesome test infrastructure by adding themselves as symlinks in `lib/`, `tests/` and `tests/examples` and otherwise use AwesomeWM Travis config. * Add an option to add examples to the C documentation. Previously only Lua functions could be documented using this framework. --- tests/examples/CMakeLists.txt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/examples/CMakeLists.txt b/tests/examples/CMakeLists.txt index 124e5b1b..ef3cad5b 100644 --- a/tests/examples/CMakeLists.txt +++ b/tests/examples/CMakeLists.txt @@ -171,9 +171,11 @@ function(run_test test_path namespace escaped_content) file(READ ${test_path} tmp_content) - # Add "--" in front of each line. This is required for method doc, but not - # for documentation pages - if(NOT tmp_content MATCHES "--DOC_NO_DASH") + # Add "--" or " * " in front of each line. This is required for method doc, + #but not for documentation pages + if(tmp_content MATCHES "--DOC_ASTERISK") + set(DOC_LINE_PREFIX " * ") + elseif(NOT tmp_content MATCHES "--DOC_NO_DASH") set(DOC_LINE_PREFIX "--") endif() @@ -279,7 +281,7 @@ function(run_test test_path namespace escaped_content) endfunction() # Find all test files, and run them (generating custom commands for updating them). -file(GLOB_RECURSE test_files LIST_DIRECTORIES false +file(GLOB_RECURSE test_files FOLLOW_SYMLINKS LIST_DIRECTORIES false "${TOP_SOURCE_DIR}/tests/examples/*.lua") # Find and run all test files. From 4e8d90704400ed51f35a65de1dd03069d8f72e60 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Sun, 22 Jul 2018 10:35:38 -0400 Subject: [PATCH 2/2] tests: Restore support for newlines in examples Since last year luacheck change, trailing spaces are no longer allowed. This caused all documentaiton examples that used them as a way to mark newlines to look plain wrong. This commit add an explicit flag to make longer examples more readable. --- tests/examples/CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/examples/CMakeLists.txt b/tests/examples/CMakeLists.txt index ef3cad5b..5a1a3ffc 100644 --- a/tests/examples/CMakeLists.txt +++ b/tests/examples/CMakeLists.txt @@ -71,7 +71,7 @@ file(MAKE_DIRECTORY "${IMAGE_DIR}") # * add "--" in front of each lines # * add a custom prefix in front of each lines # * drop empty lines -# * convert " " lines into empty lines +# * convert --DOC_NEWLINE lines into empty lines # * drop lines ending with "--DOC_SOMETHING", they are handled elsewhere function(escape_string variable content escaped_content line_prefix) # If DOC_HIDE_ALL is present, do nothing. @@ -82,6 +82,10 @@ function(escape_string variable content escaped_content line_prefix) set(tmp_output ${content}) foreach (LINE ${var_lines}) + + # ;; will drop the line, but " ;" will create an empty line + string(REGEX REPLACE "--DOC_NEWLINE" " " LINE "${LINE}") + if(NOT LINE MATCHES "^.*--DOC_[A-Z]+") set(tmp_output ${tmp_output}\n${DOC_LINE_PREFIX}${line_prefix}${LINE}) endif()