]> git.lyx.org Git - features.git/commitdiff
Cmake export tests: Check for reused labels included
authorKornel Benko <kornel@lyx.org>
Tue, 24 Nov 2015 20:23:38 +0000 (21:23 +0100)
committerKornel Benko <kornel@lyx.org>
Tue, 24 Nov 2015 20:23:38 +0000 (21:23 +0100)
Labels defined in .*Tests should be unique. Now at least a warning is
produced.

development/autotests/ExportTests.cmake

index 7ab627ed621d40eebbc0e4b8dfd07551feac69d8..072cc02eac27aa88a40d98c83d3f77a48ecf20bf 100644 (file)
@@ -143,18 +143,29 @@ macro(maketestname testname reverted listreverted listignored listunreliable lis
   endif()
 endmacro()
 
+# This labels should not be used in .*Tests files
+set(known_labels "export" "key" "layout" "load" "lyx2lyx"
+  "examples" "manuals" "mathmacros" "reverted" "templates" "unreliable" "suspended" 
+  "module" "roundtrip" "url")
+
 macro(loadTestList filename resList)
   # Create list of strings from a file without comments
   file(STRINGS ${filename} tempList ENCODING "UTF-8")
   set(${resList})
   set(sublabel)
+  set(mylabels "")
   foreach(_l ${tempList})
     set(_newl "${_l}")
     string(REGEX REPLACE "[ \t]*#.*$" "" _newl "${_l}")
     if(_newl)
       string(REGEX REPLACE "(\\/|\\||\\(|\\))" "  " _vxx ${_newl})
       string(REGEX MATCHALL " ([a-z][a-z](_[A-Z][A-Z])?) " _vx ${_vxx})
-      if (_newl MATCHES "^Sublabel:")
+      if (_newl MATCHES "^Sublabel:[ \t]*\([a-zA-Z]+\)")
+        set(labname ${CMAKE_MATCH_1})
+        if (NOT labname STREQUAL "RESET")
+          list(REMOVE_ITEM mylabels ${labname})
+          list(APPEND mylabels ${labname})
+        endif()
         set(sublabel ${_newl})
       endif()
       if(_vx)
@@ -177,12 +188,20 @@ macro(loadTestList filename resList)
       endif()
     endif()
   endforeach()
+  foreach(_l ${mylabels})
+    list(FIND known_labels ${_l} _ff)
+    if (_ff GREATER -1)
+      message(STATUS "Label \"${_l}\" already in use. Reused in ${filename}")
+    else()
+      list(APPEND known_labels ${_l})
+    endif()
+  endforeach()
 endmacro()
 
-loadTestList(revertedTests revertedTests)
-loadTestList(ignoredTests ignoredTests)
-loadTestList(suspendedTests suspendedTests)
-loadTestList(unreliableTests unreliableTests)
+loadTestList(revertedTests revertedTests new_labels)
+loadTestList(ignoredTests ignoredTests new_labels)
+loadTestList(suspendedTests suspendedTests new_labels)
+loadTestList(unreliableTests unreliableTests new_labels)
 
 macro(handlesuspended TestName reverted testlabel)
   set(mylabel ${${testlabel}})