chiark / gitweb /
documentation: make the general search tests backend-independent.
authorVladimír Vondruš <mosra@centrum.cz>
Thu, 18 Jul 2019 09:24:04 +0000 (11:24 +0200)
committerVladimír Vondruš <mosra@centrum.cz>
Thu, 18 Jul 2019 15:41:34 +0000 (17:41 +0200)
It stays C++-specific, but since the implementation doesn't care about
the language, it's okay.

18 files changed:
CONTRIBUTING.rst
documentation/test/__init__.py [new file with mode: 0644]
documentation/test/_search_test_metadata.py [new file with mode: 0644]
documentation/test/js-test-data/.gitattributes [moved from documentation/test_doxygen/js-test-data/.gitattributes with 100% similarity]
documentation/test/js-test-data/empty.bin [moved from documentation/test_doxygen/js-test-data/empty.bin with 100% similarity]
documentation/test/js-test-data/nested.bin [new file with mode: 0644]
documentation/test/js-test-data/searchdata.b85 [moved from documentation/test_doxygen/js-test-data/searchdata.b85 with 68% similarity]
documentation/test/js-test-data/searchdata.bin [moved from documentation/test_doxygen/js-test-data/searchdata.bin with 77% similarity]
documentation/test/js-test-data/short.bin [moved from documentation/test_doxygen/js-test-data/short.bin with 100% similarity]
documentation/test/js-test-data/unicode.bin [moved from documentation/test_doxygen/js-test-data/unicode.bin with 55% similarity]
documentation/test/js-test-data/wrong-magic.bin [moved from documentation/test_doxygen/js-test-data/wrong-magic.bin with 100% similarity]
documentation/test/js-test-data/wrong-version.bin [moved from documentation/test_doxygen/js-test-data/wrong-version.bin with 100% similarity]
documentation/test/populate-js-test-data.py [moved from documentation/test_doxygen/populate-js-test-data.py with 97% similarity]
documentation/test/test-search.js [moved from documentation/test_doxygen/test-search.js with 97% similarity]
documentation/test/test_search.py [new file with mode: 0755]
documentation/test_doxygen/js-test-data/nested.bin [deleted file]
documentation/test_doxygen/test_search.py
package/ci/travis.yml

index 32057e93e932656035049bf561f890cc1befe010..e26c32b7b5b3765f713ceb689d9a421c7747aded 100644 (file)
@@ -109,7 +109,7 @@ There is no possibility of getting code coverage for Jinja2 templates, though.
     # open htmlcov/index.html in your browser
 
     cd documentation
-    node ./node_modules/istanbul/lib/cli.js cover test_doxygen/test-search.js
+    node ./node_modules/istanbul/lib/cli.js cover test/test-search.js
     # open coverage/lcov-report/index.html in your browser
 
     cd plugins
diff --git a/documentation/test/__init__.py b/documentation/test/__init__.py
new file mode 100644 (file)
index 0000000..e2a942e
--- /dev/null
@@ -0,0 +1,23 @@
+#
+#   This file is part of m.css.
+#
+#   Copyright © 2017, 2018, 2019 Vladimír Vondruš <mosra@centrum.cz>
+#
+#   Permission is hereby granted, free of charge, to any person obtaining a
+#   copy of this software and associated documentation files (the "Software"),
+#   to deal in the Software without restriction, including without limitation
+#   the rights to use, copy, modify, merge, publish, distribute, sublicense,
+#   and/or sell copies of the Software, and to permit persons to whom the
+#   Software is furnished to do so, subject to the following conditions:
+#
+#   The above copyright notice and this permission notice shall be included
+#   in all copies or substantial portions of the Software.
+#
+#   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+#   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+#   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+#   THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+#   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+#   FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+#   DEALINGS IN THE SOFTWARE.
+#
diff --git a/documentation/test/_search_test_metadata.py b/documentation/test/_search_test_metadata.py
new file mode 100644 (file)
index 0000000..abe6f1a
--- /dev/null
@@ -0,0 +1,46 @@
+#
+#   This file is part of m.css.
+#
+#   Copyright © 2017, 2018, 2019 Vladimír Vondruš <mosra@centrum.cz>
+#
+#   Permission is hereby granted, free of charge, to any person obtaining a
+#   copy of this software and associated documentation files (the "Software"),
+#   to deal in the Software without restriction, including without limitation
+#   the rights to use, copy, modify, merge, publish, distribute, sublicense,
+#   and/or sell copies of the Software, and to permit persons to whom the
+#   Software is furnished to do so, subject to the following conditions:
+#
+#   The above copyright notice and this permission notice shall be included
+#   in all copies or substantial portions of the Software.
+#
+#   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+#   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+#   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+#   THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+#   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+#   FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+#   DEALINGS IN THE SOFTWARE.
+#
+
+import enum
+
+from _search import CssClass
+
+# Taken from doxygen.py, with stuff that's unused in the generic tests removed.
+# It's C++-specific but the implementation doesn't really care, actually ;)
+
+class EntryType(enum.Enum):
+    # Order must match the search_type_map below; first value is reserved for
+    # ResultFlag.ALIAS
+    PAGE = 1
+    NAMESPACE = 2
+    CLASS = 3
+    FUNC = 4
+
+# Order must match the EntryType above
+search_type_map = [
+    (CssClass.SUCCESS, "page"),
+    (CssClass.PRIMARY, "namespace"),
+    (CssClass.PRIMARY, "class"),
+    (CssClass.INFO, "func")
+]
diff --git a/documentation/test/js-test-data/nested.bin b/documentation/test/js-test-data/nested.bin
new file mode 100644 (file)
index 0000000..6a92cb9
Binary files /dev/null and b/documentation/test/js-test-data/nested.bin differ
similarity index 68%
rename from documentation/test_doxygen/js-test-data/searchdata.b85
rename to documentation/test/js-test-data/searchdata.b85
index 3239298ae56a7e3098f8d65ad053e2ebb302c0dc..1de2e51861749ca20e300b3aef944a31cef9bfc3 100644 (file)
@@ -1 +1 @@
-O+!-w2LOZt004pl003kG000310RR921ONaj009U904M+f4gdgd009&L0BHdL0{{R4AOHX<00ATb04M+fDgXd(00A%n0BHaLHUI!^00BGz06GBy0suk)fI0vHNB{tG00B?{0B-;RRsaBW00CS80Am0FVgLYT0RRO600C|Q04V?gasU7*00DRa0B!&QegFVz00D#m0BryPiU0sQ0RaR6kN|)>00EW&0A&CHo&W%600E=`0B!&QssI3C00SBT0BvXh0Cund0CE5Uwg3P+0RaF2!~lRg00GJX0B8UK(f|N-0{{U40{{g800G_r04V?g<^TXF00Ha(0B!&R*Z=@w@&Ev70RRU8009C40A&CH1_1zU009gE0A~OJ5&-~i0RadA7y$rb00ABW0CWHWCIJ9r00OE20AVZv0A&FH1^@s7JOKb@00BS&0A~OJMgag}00B$^0B`^SQUL&B00CG50CfNa_y7QHXaE3qG64W`UI74eC;$K;KL7x!R{#J?djJ5bkpKWlvj70C$p8Ql<p2Nx@Bjb_{r~^~O<{Cs0B&JzWpi+0V`WWYbZ9PUbZu+^01^l~I&EogC~0nVEFfuabSVHMZE0=*0025VR%K&!Z*l-*Y+-YAO<{CsUol@XR%K&!Z*neZbZu+`02l^3I&EogC@COgZ*FsR03&T_ZU6uPIyzEeZf9ixV{Bn_b4_7%XkRg3F;Zb}XJsyEbZu+|02c;2I&EogC@COgZ*FsR03&T_Zct%oWgx=4AX9Z>aA9X<0CRO>aA9X<E@*UZYy<#OWn*+<Zf9&|1ONvB00KHXQe|UwC@BIS0U`n`0WbkI0XqRe14jc&1x^K00ayTB0Av7XaA9X<ZeeX@b8ul}WoL44b#P;BVRLhHbaHiLbaifNZ*FvXaAjm=W@Kq{W@&6?W_503WMyV)Ze?X|b!}yCb!{MaVQh9`asU7T
\ No newline at end of file
+O+!-w2LOZt004pl003kG000310RR921ONaj009U904M+f4gdgd009&L0BHdL0{{R4AOHX<00ATb04M+fDgXd(00A%n0BHaLHUI!^00BGz06GBy0suk)fI0vHNB{tG00B?{0B-;RRsaBW00CS80Am0FVgLYT0RRO600C|Q04V?gasU7*00DRa0B!&QegFVz00D#m0BryPiU0sQ0RaR6kN|)>00EW&0A&CHo&W%600E=`0B!&QssI3C00SBT0BvXh0Cund0CE5Uwg3P+0RaF2!~lRg00GJX0B8UK(f|N-0{{U40{{g800G_r04V?g<^TXF00Ha(0B!&R*Z=@w@&Ev70RRU8009C40A&CH1_1zU009gE0A~OJ5&-~i0RadA7y$rb00ABW0CWHWCIJ9r00OE20AVZv0A&FH1^@s7JOKb@00BS&0A~OJMgag}00B$^0B`^SQUL&B00CG50CfNa_y7QHXaE3qG64W`UI74eC;$K;KL7wpR{#JydjJ4QkpKWVvj6~1$p8Ql<p2Nx@Bjb_{r~^~O<{Cs0B&JzWpi+0V`WWYbZ9PUbZu+^01^l~I&EogC~0nVEFfuabSVHMZE0=*0025VR%K&!Z*l-*Y+-YAO<{CsUol@XR%K&!Z*neZbZu+`02l^3I&EogC@COgZ*FsR03&T_ZU6uPIyzEeZf9ixV{Bn_b4_7%XkRg3F;Zb}XJsyEbZu+|02c;2I&EogC@COgZ*FsR03&T_Zct%oWgx=4AX9Z>aA9X<0CRO>aA9X<E@*UZYy<#OWn*+<Zf9&|1ONvB00KHXQe|UwC@BI80S*Bd1snh%aA9X<ZeeX@b8ul}Wn*k%b8}{OZesud
\ No newline at end of file
similarity index 77%
rename from documentation/test_doxygen/js-test-data/searchdata.bin
rename to documentation/test/js-test-data/searchdata.bin
index 319ef59a772e7ed876620be5c2a7106ad281b2c3..dfc16df1941fdb5db84fbdca6c2c75cbb9a6cf42 100644 (file)
Binary files a/documentation/test_doxygen/js-test-data/searchdata.bin and b/documentation/test/js-test-data/searchdata.bin differ
similarity index 55%
rename from documentation/test_doxygen/js-test-data/unicode.bin
rename to documentation/test/js-test-data/unicode.bin
index a4facc452d2c7ca159d9013fafa8114279b76b73..132cec998a3484675fc17a0353b3b7f784e3dbca 100644 (file)
Binary files a/documentation/test_doxygen/js-test-data/unicode.bin and b/documentation/test/js-test-data/unicode.bin differ
similarity index 97%
rename from documentation/test_doxygen/populate-js-test-data.py
rename to documentation/test/populate-js-test-data.py
index 9ca5f91bfbd4563f156db815bcd3ea6112c59115..6c5324ba250d9fa9d7d985b333177542799c3964 100755 (executable)
@@ -28,9 +28,10 @@ import base64
 import os
 import sys
 import pathlib
+sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__))))
 sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), '..'))
 
-from doxygen import EntryType, search_type_map
+from _search_test_metadata import EntryType, search_type_map
 from _search import Trie, ResultMap, ResultFlag, serialize_search_data
 
 basedir = pathlib.Path(os.path.dirname(os.path.realpath(__file__)))/'js-test-data'
similarity index 97%
rename from documentation/test_doxygen/test-search.js
rename to documentation/test/test-search.js
index d95c31f5cc8a89e3ddb65105d3d5a2d6ba6905ce..2bf9cc7afab9e3d17789909a442b9d8899e6b071 100644 (file)
@@ -79,7 +79,7 @@ const { StringDecoder } = require('string_decoder');
 /* Verify that base85-decoded file is equivalent to the binary */
 {
     let binary = fs.readFileSync(path.join(__dirname, "js-test-data/searchdata.bin"));
-    assert.equal(binary.byteLength, 745);
+    assert.equal(binary.byteLength, 674);
     let b85 = fs.readFileSync(path.join(__dirname, "js-test-data/searchdata.b85"), {encoding: 'utf-8'});
     assert.deepEqual(new DataView(binary.buffer.slice(binary.byteOffset, binary.byteOffset + binary.byteLength)), new DataView(Search.base85decode(b85), 0, binary.byteLength));
 }
@@ -114,7 +114,7 @@ const { StringDecoder } = require('string_decoder');
 {
     let buffer = fs.readFileSync(path.join(__dirname, "js-test-data/searchdata.bin"));
     assert.ok(Search.init(buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength)));
-    assert.equal(Search.dataSize, 745);
+    assert.equal(Search.dataSize, 674);
     assert.equal(Search.symbolCount, 7);
     assert.equal(Search.maxResults, 100);
 
@@ -223,7 +223,7 @@ const { StringDecoder } = require('string_decoder');
 {
     let buffer = fs.readFileSync(path.join(__dirname, "js-test-data/searchdata.bin"));
     assert.ok(Search.init(buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength), 3));
-    assert.equal(Search.dataSize, 745);
+    assert.equal(Search.dataSize, 674);
     assert.equal(Search.symbolCount, 7);
     assert.equal(Search.maxResults, 3);
     assert.deepEqual(Search.search('m'), [[
@@ -251,7 +251,7 @@ const { StringDecoder } = require('string_decoder');
 {
     let b85 = fs.readFileSync(path.join(__dirname, "js-test-data/searchdata.b85"), {encoding: 'utf-8'});
     assert.ok(Search.load(b85));
-    assert.equal(Search.dataSize, 748); /* some padding on the end, that's okay */
+    assert.equal(Search.dataSize, 676); /* some padding on the end, that's okay */
     assert.equal(Search.symbolCount, 7);
     assert.equal(Search.maxResults, 100);
     assert.deepEqual(Search.search('min'), [[
@@ -279,7 +279,7 @@ const { StringDecoder } = require('string_decoder');
 {
     let buffer = fs.readFileSync(path.join(__dirname, "js-test-data/unicode.bin"));
     assert.ok(Search.init(buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength)));
-    assert.equal(Search.dataSize, 231);
+    assert.equal(Search.dataSize, 160);
     assert.equal(Search.symbolCount, 2);
     /* Both "Hýždě" and "Hárá" have common autocompletion to "h\xA1", which is
        not valid UTF-8, so it has to get truncated */
@@ -317,7 +317,7 @@ const { StringDecoder } = require('string_decoder');
 {
     let buffer = fs.readFileSync(path.join(__dirname, "js-test-data/nested.bin"));
     assert.ok(Search.init(buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength)));
-    assert.equal(Search.dataSize, 402);
+    assert.equal(Search.dataSize, 331);
     assert.equal(Search.symbolCount, 4);
     assert.deepEqual(Search.search('geo'), [[
         { name: 'Magnum::Math::Geometry',
diff --git a/documentation/test/test_search.py b/documentation/test/test_search.py
new file mode 100755 (executable)
index 0000000..05424a4
--- /dev/null
@@ -0,0 +1,238 @@
+#
+#   This file is part of m.css.
+#
+#   Copyright © 2017, 2018, 2019 Vladimír Vondruš <mosra@centrum.cz>
+#
+#   Permission is hereby granted, free of charge, to any person obtaining a
+#   copy of this software and associated documentation files (the "Software"),
+#   to deal in the Software without restriction, including without limitation
+#   the rights to use, copy, modify, merge, publish, distribute, sublicense,
+#   and/or sell copies of the Software, and to permit persons to whom the
+#   Software is furnished to do so, subject to the following conditions:
+#
+#   The above copyright notice and this permission notice shall be included
+#   in all copies or substantial portions of the Software.
+#
+#   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+#   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+#   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+#   THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+#   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+#   FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+#   DEALINGS IN THE SOFTWARE.
+#
+
+import os
+import sys
+import unittest
+from types import SimpleNamespace as Empty
+
+from ._search_test_metadata import EntryType, search_type_map
+from _search import Trie, ResultMap, ResultFlag, serialize_search_data, pretty_print_trie, pretty_print_map, pretty_print, searchdata_filename
+
+from test_doxygen import IntegrationTestCase
+
+class TrieSerialization(unittest.TestCase):
+    def __init__(self, *args, **kwargs):
+        super().__init__(*args, **kwargs)
+        self.maxDiff = None
+
+    def compare(self, serialized: bytes, expected: str):
+        pretty = pretty_print_trie(serialized)[0]
+        #print(pretty)
+        self.assertEqual(pretty, expected.strip())
+
+    def test_empty(self):
+        trie = Trie()
+
+        serialized = trie.serialize()
+        self.compare(serialized, "")
+        self.assertEqual(len(serialized), 6)
+
+    def test_single(self):
+        trie = Trie()
+        trie.insert("magnum", 1337)
+        trie.insert("magnum", 21)
+
+        serialized = trie.serialize()
+        self.compare(serialized, """
+magnum [1337, 21]
+""")
+        self.assertEqual(len(serialized), 46)
+
+    def test_multiple(self):
+        trie = Trie()
+
+        trie.insert("math", 0)
+        trie.insert("math::vector", 1, lookahead_barriers=[4])
+        trie.insert("vector", 1)
+        trie.insert("math::range", 2)
+        trie.insert("range", 2)
+
+        trie.insert("math::min", 3)
+        trie.insert("min", 3)
+        trie.insert("math::max", 4)
+        trie.insert("max", 4)
+        trie.insert("math::minmax", 5)
+        trie.insert("minmax", 5)
+
+        trie.insert("math::vector::minmax", 6, lookahead_barriers=[4, 12])
+        trie.insert("vector::minmax", 6, lookahead_barriers=[6])
+        trie.insert("minmax", 6)
+        trie.insert("math::vector::min", 7)
+        trie.insert("vector::min", 7)
+        trie.insert("min", 7)
+        trie.insert("math::vector::max", 8)
+        trie.insert("vector::max", 8)
+        trie.insert("max", 8)
+
+        trie.insert("math::range::min", 9, lookahead_barriers=[4, 11])
+        trie.insert("range::min", 9, lookahead_barriers=[5])
+        trie.insert("min", 9)
+
+        trie.insert("math::range::max", 10)
+        trie.insert("range::max", 10)
+        trie.insert("max", 10)
+
+        serialized = trie.serialize()
+        self.compare(serialized, """
+math [0]
+||| :$
+|||  :vector [1]
+|||   |     :$
+|||   |      :min [7]
+|||   |        | max [6]
+|||   |        ax [8]
+|||   range [2]
+|||   |    :$
+|||   |     :min [9]
+|||   |       ax [10]
+|||   min [3]
+|||   || max [5]
+|||   |ax [4]
+||x [4, 8, 10]
+|in [3, 7, 9]
+|| max [5, 6]
+vector [1]
+|     :$
+|      :min [7]
+|        | max [6]
+|        ax [8]
+range [2]
+|    :$
+|     :min [9]
+|       ax [10]
+""")
+        self.assertEqual(len(serialized), 340)
+
+    def test_unicode(self):
+        trie = Trie()
+
+        trie.insert("hýždě", 0)
+        trie.insert("hárá", 1)
+
+        serialized = trie.serialize()
+        self.compare(serialized, """
+h0xc3
+  0xbd
+   0xc5
+  | 0xbe
+  |  d0xc4
+  |    0x9b
+  |      [0]
+  0xa1
+   r0xc3
+  |  0xa1
+  |    [1]
+""")
+        self.assertEqual(len(serialized), 82)
+
+class MapSerialization(unittest.TestCase):
+    def __init__(self, *args, **kwargs):
+        super().__init__(*args, **kwargs)
+        self.maxDiff = None
+
+    def compare(self, serialized: bytes, expected: str):
+        pretty = pretty_print_map(serialized, entryTypeClass=EntryType)
+        #print(pretty)
+        self.assertEqual(pretty, expected.strip())
+
+    def test_empty(self):
+        map = ResultMap()
+
+        serialized = map.serialize()
+        self.compare(serialized, "")
+        self.assertEqual(len(serialized), 4)
+
+    def test_single(self):
+        map = ResultMap()
+        self.assertEqual(map.add("Magnum", "namespaceMagnum.html", suffix_length=11, flags=ResultFlag.from_type(ResultFlag.NONE, EntryType.NAMESPACE)), 0)
+
+        serialized = map.serialize()
+        self.compare(serialized, """
+0: Magnum [suffix_length=11, type=NAMESPACE] -> namespaceMagnum.html
+""")
+        self.assertEqual(len(serialized), 36)
+
+    def test_multiple(self):
+        map = ResultMap()
+
+        self.assertEqual(map.add("Math", "namespaceMath.html", flags=ResultFlag.from_type(ResultFlag.NONE, EntryType.NAMESPACE)), 0)
+        self.assertEqual(map.add("Math::Vector", "classMath_1_1Vector.html", flags=ResultFlag.from_type(ResultFlag.NONE, EntryType.CLASS)), 1)
+        self.assertEqual(map.add("Math::Range", "classMath_1_1Range.html", flags=ResultFlag.from_type(ResultFlag.NONE, EntryType.CLASS)), 2)
+        self.assertEqual(map.add("Math::min()", "namespaceMath.html#abcdef2875", flags=ResultFlag.from_type(ResultFlag.NONE, EntryType.FUNC)), 3)
+        self.assertEqual(map.add("Math::max(int, int)", "namespaceMath.html#abcdef1234", suffix_length=8, flags=ResultFlag.from_type(ResultFlag.DEPRECATED|ResultFlag.DELETED, EntryType.FUNC)), 4)
+        self.assertEqual(map.add("Rectangle", "", alias=2), 5)
+        self.assertEqual(map.add("Rectangle::Rect()", "", suffix_length=2, alias=2), 6)
+
+        serialized = map.serialize()
+        self.compare(serialized, """
+0: Math [type=NAMESPACE] -> namespaceMath.html
+1: ::Vector [prefix=0[:0], type=CLASS] -> classMath_1_1Vector.html
+2: ::Range [prefix=0[:0], type=CLASS] -> classMath_1_1Range.html
+3: ::min() [prefix=0[:18], type=FUNC] -> #abcdef2875
+4: ::max(int, int) [prefix=0[:18], suffix_length=8, deprecated, deleted, type=FUNC] -> #abcdef1234
+5: Rectangle [alias=2] ->
+6: ::Rect() [alias=2, prefix=5[:0], suffix_length=2] ->
+""")
+        self.assertEqual(len(serialized), 203)
+
+class Serialization(unittest.TestCase):
+    def __init__(self, *args, **kwargs):
+        super().__init__(*args, **kwargs)
+        self.maxDiff = None
+
+    def compare(self, serialized: bytes, expected: str):
+        pretty = pretty_print(serialized, entryTypeClass=EntryType)[0]
+        #print(pretty)
+        self.assertEqual(pretty, expected.strip())
+
+    def test(self):
+        trie = Trie()
+        map = ResultMap()
+
+        trie.insert("math", map.add("Math", "namespaceMath.html", flags=ResultFlag.from_type(ResultFlag.NONE, EntryType.NAMESPACE)))
+        index = map.add("Math::Vector", "classMath_1_1Vector.html", flags=ResultFlag.from_type(ResultFlag.NONE, EntryType.CLASS))
+        trie.insert("math::vector", index)
+        trie.insert("vector", index)
+        index = map.add("Math::Range", "classMath_1_1Range.html", flags=ResultFlag.from_type(ResultFlag.NONE, EntryType.CLASS))
+        trie.insert("math::range", index)
+        trie.insert("range", index)
+
+        serialized = serialize_search_data(trie, map, search_type_map, 3)
+        self.compare(serialized, """
+3 symbols
+math [0]
+|   ::vector [1]
+|     range [2]
+vector [1]
+range [2]
+0: Math [type=NAMESPACE] -> namespaceMath.html
+1: ::Vector [prefix=0[:0], type=CLASS] -> classMath_1_1Vector.html
+2: ::Range [prefix=0[:0], type=CLASS] -> classMath_1_1Range.html
+(EntryType.PAGE, CssClass.SUCCESS, 'page'),
+(EntryType.NAMESPACE, CssClass.PRIMARY, 'namespace'),
+(EntryType.CLASS, CssClass.PRIMARY, 'class'),
+(EntryType.FUNC, CssClass.INFO, 'func')
+""")
+        self.assertEqual(len(serialized), 277)
diff --git a/documentation/test_doxygen/js-test-data/nested.bin b/documentation/test_doxygen/js-test-data/nested.bin
deleted file mode 100644 (file)
index 39d332c..0000000
Binary files a/documentation/test_doxygen/js-test-data/nested.bin and /dev/null differ
index 707c748e1212ff2f49b62257fb9da37325ed72de..4ed0a3c49c540a3e486925bf16525d2177939ce6 100755 (executable)
 import argparse
 import os
 import sys
-import unittest
-from types import SimpleNamespace as Empty
 
-from doxygen import EntryType, search_type_map
-from _search import Trie, ResultMap, ResultFlag, serialize_search_data, pretty_print_trie, pretty_print_map, pretty_print, searchdata_filename
+from doxygen import EntryType
+from _search import pretty_print, searchdata_filename
 
 from test_doxygen import IntegrationTestCase
 
-class TrieSerialization(unittest.TestCase):
-    def __init__(self, *args, **kwargs):
-        super().__init__(*args, **kwargs)
-        self.maxDiff = None
-
-    def compare(self, serialized: bytes, expected: str):
-        pretty = pretty_print_trie(serialized)[0]
-        #print(pretty)
-        self.assertEqual(pretty, expected.strip())
-
-    def test_empty(self):
-        trie = Trie()
-
-        serialized = trie.serialize()
-        self.compare(serialized, "")
-        self.assertEqual(len(serialized), 6)
-
-    def test_single(self):
-        trie = Trie()
-        trie.insert("magnum", 1337)
-        trie.insert("magnum", 21)
-
-        serialized = trie.serialize()
-        self.compare(serialized, """
-magnum [1337, 21]
-""")
-        self.assertEqual(len(serialized), 46)
-
-    def test_multiple(self):
-        trie = Trie()
-
-        trie.insert("math", 0)
-        trie.insert("math::vector", 1, lookahead_barriers=[4])
-        trie.insert("vector", 1)
-        trie.insert("math::range", 2)
-        trie.insert("range", 2)
-
-        trie.insert("math::min", 3)
-        trie.insert("min", 3)
-        trie.insert("math::max", 4)
-        trie.insert("max", 4)
-        trie.insert("math::minmax", 5)
-        trie.insert("minmax", 5)
-
-        trie.insert("math::vector::minmax", 6, lookahead_barriers=[4, 12])
-        trie.insert("vector::minmax", 6, lookahead_barriers=[6])
-        trie.insert("minmax", 6)
-        trie.insert("math::vector::min", 7)
-        trie.insert("vector::min", 7)
-        trie.insert("min", 7)
-        trie.insert("math::vector::max", 8)
-        trie.insert("vector::max", 8)
-        trie.insert("max", 8)
-
-        trie.insert("math::range::min", 9, lookahead_barriers=[4, 11])
-        trie.insert("range::min", 9, lookahead_barriers=[5])
-        trie.insert("min", 9)
-
-        trie.insert("math::range::max", 10)
-        trie.insert("range::max", 10)
-        trie.insert("max", 10)
-
-        serialized = trie.serialize()
-        self.compare(serialized, """
-math [0]
-||| :$
-|||  :vector [1]
-|||   |     :$
-|||   |      :min [7]
-|||   |        | max [6]
-|||   |        ax [8]
-|||   range [2]
-|||   |    :$
-|||   |     :min [9]
-|||   |       ax [10]
-|||   min [3]
-|||   || max [5]
-|||   |ax [4]
-||x [4, 8, 10]
-|in [3, 7, 9]
-|| max [5, 6]
-vector [1]
-|     :$
-|      :min [7]
-|        | max [6]
-|        ax [8]
-range [2]
-|    :$
-|     :min [9]
-|       ax [10]
-""")
-        self.assertEqual(len(serialized), 340)
-
-    def test_unicode(self):
-        trie = Trie()
-
-        trie.insert("hýždě", 0)
-        trie.insert("hárá", 1)
-
-        serialized = trie.serialize()
-        self.compare(serialized, """
-h0xc3
-  0xbd
-   0xc5
-  | 0xbe
-  |  d0xc4
-  |    0x9b
-  |      [0]
-  0xa1
-   r0xc3
-  |  0xa1
-  |    [1]
-""")
-        self.assertEqual(len(serialized), 82)
-
-class MapSerialization(unittest.TestCase):
-    def __init__(self, *args, **kwargs):
-        super().__init__(*args, **kwargs)
-        self.maxDiff = None
-
-    def compare(self, serialized: bytes, expected: str):
-        pretty = pretty_print_map(serialized, entryTypeClass=EntryType)
-        #print(pretty)
-        self.assertEqual(pretty, expected.strip())
-
-    def test_empty(self):
-        map = ResultMap()
-
-        serialized = map.serialize()
-        self.compare(serialized, "")
-        self.assertEqual(len(serialized), 4)
-
-    def test_single(self):
-        map = ResultMap()
-        self.assertEqual(map.add("Magnum", "namespaceMagnum.html", suffix_length=11, flags=ResultFlag.from_type(ResultFlag.NONE, EntryType.NAMESPACE)), 0)
-
-        serialized = map.serialize()
-        self.compare(serialized, """
-0: Magnum [suffix_length=11, type=NAMESPACE] -> namespaceMagnum.html
-""")
-        self.assertEqual(len(serialized), 36)
-
-    def test_multiple(self):
-        map = ResultMap()
-
-        self.assertEqual(map.add("Math", "namespaceMath.html", flags=ResultFlag.from_type(ResultFlag.NONE, EntryType.NAMESPACE)), 0)
-        self.assertEqual(map.add("Math::Vector", "classMath_1_1Vector.html", flags=ResultFlag.from_type(ResultFlag.NONE, EntryType.CLASS)), 1)
-        self.assertEqual(map.add("Math::Range", "classMath_1_1Range.html", flags=ResultFlag.from_type(ResultFlag.NONE, EntryType.CLASS)), 2)
-        self.assertEqual(map.add("Math::min()", "namespaceMath.html#abcdef2875", flags=ResultFlag.from_type(ResultFlag.NONE, EntryType.FUNC)), 3)
-        self.assertEqual(map.add("Math::max(int, int)", "namespaceMath.html#abcdef1234", suffix_length=8, flags=ResultFlag.from_type(ResultFlag.DEPRECATED|ResultFlag.DELETED, EntryType.FUNC)), 4)
-        self.assertEqual(map.add("Rectangle", "", alias=2), 5)
-        self.assertEqual(map.add("Rectangle::Rect()", "", suffix_length=2, alias=2), 6)
-
-        serialized = map.serialize()
-        self.compare(serialized, """
-0: Math [type=NAMESPACE] -> namespaceMath.html
-1: ::Vector [prefix=0[:0], type=CLASS] -> classMath_1_1Vector.html
-2: ::Range [prefix=0[:0], type=CLASS] -> classMath_1_1Range.html
-3: ::min() [prefix=0[:18], type=FUNC] -> #abcdef2875
-4: ::max(int, int) [prefix=0[:18], suffix_length=8, deprecated, deleted, type=FUNC] -> #abcdef1234
-5: Rectangle [alias=2] ->
-6: ::Rect() [alias=2, prefix=5[:0], suffix_length=2] ->
-""")
-        self.assertEqual(len(serialized), 203)
-
-class Serialization(unittest.TestCase):
-    def __init__(self, *args, **kwargs):
-        super().__init__(*args, **kwargs)
-        self.maxDiff = None
-
-    def compare(self, serialized: bytes, expected: str):
-        pretty = pretty_print(serialized, entryTypeClass=EntryType)[0]
-        #print(pretty)
-        self.assertEqual(pretty, expected.strip())
-
-    def test(self):
-        trie = Trie()
-        map = ResultMap()
-
-        trie.insert("math", map.add("Math", "namespaceMath.html", flags=ResultFlag.from_type(ResultFlag.NONE, EntryType.NAMESPACE)))
-        index = map.add("Math::Vector", "classMath_1_1Vector.html", flags=ResultFlag.from_type(ResultFlag.NONE, EntryType.CLASS))
-        trie.insert("math::vector", index)
-        trie.insert("vector", index)
-        index = map.add("Math::Range", "classMath_1_1Range.html", flags=ResultFlag.from_type(ResultFlag.NONE, EntryType.CLASS))
-        trie.insert("math::range", index)
-        trie.insert("range", index)
-
-        serialized = serialize_search_data(trie, map, search_type_map, 3)
-        self.compare(serialized, """
-3 symbols
-math [0]
-|   ::vector [1]
-|     range [2]
-vector [1]
-range [2]
-0: Math [type=NAMESPACE] -> namespaceMath.html
-1: ::Vector [prefix=0[:0], type=CLASS] -> classMath_1_1Vector.html
-2: ::Range [prefix=0[:0], type=CLASS] -> classMath_1_1Range.html
-(EntryType.PAGE, CssClass.SUCCESS, 'page'),
-(EntryType.NAMESPACE, CssClass.PRIMARY, 'namespace'),
-(EntryType.GROUP, CssClass.SUCCESS, 'group'),
-(EntryType.CLASS, CssClass.PRIMARY, 'class'),
-(EntryType.STRUCT, CssClass.PRIMARY, 'struct'),
-(EntryType.UNION, CssClass.PRIMARY, 'union'),
-(EntryType.TYPEDEF, CssClass.PRIMARY, 'typedef'),
-(EntryType.DIR, CssClass.WARNING, 'dir'),
-(EntryType.FILE, CssClass.WARNING, 'file'),
-(EntryType.FUNC, CssClass.INFO, 'func'),
-(EntryType.DEFINE, CssClass.INFO, 'define'),
-(EntryType.ENUM, CssClass.PRIMARY, 'enum'),
-(EntryType.ENUM_VALUE, CssClass.DEFAULT, 'enum val'),
-(EntryType.VAR, CssClass.DEFAULT, 'var')
-""")
-        self.assertEqual(len(serialized), 348)
-
 class Search(IntegrationTestCase):
     def __init__(self, *args, **kwargs):
         super().__init__(__file__, '', *args, **kwargs)
index a7e6d7f7486d5e530c011724725ee2d90eff3290..d0eac53e8f21127aec049f9882f5ecc2a60bede9 100644 (file)
@@ -79,7 +79,7 @@ script:
   - if [ "$WITH_DOCUMENTATION" == "ON" ]; then cd $TRAVIS_BUILD_DIR/documentation && coverage run -m unittest && cp .coverage ../.coverage.doxygen; fi
 
   # Test client doxygen JS
-  - if [ "$WITH_NODE" == "ON" ]; then cd $TRAVIS_BUILD_DIR/documentation && node ../node_modules/istanbul/lib/cli.js cover test_doxygen/test-search.js; fi
+  - if [ "$WITH_NODE" == "ON" ]; then cd $TRAVIS_BUILD_DIR/documentation && node ../node_modules/istanbul/lib/cli.js cover test/test-search.js; fi
 
   # Test that compiled CSS is up-to-date. First display the diff, then check
   # with diff-index which should print what's wrong and return with non-zero
@@ -90,8 +90,8 @@ script:
   # Test that JS search test data are up-to-date as well. Would be best to do
   # it on the Node.js job but that one has just Python 3.5 which doesn't know
   # enum.Flag.
-  - if [ "$WITH_DOCUMENTATION" == "ON" ]; then cd $TRAVIS_BUILD_DIR/documentation/test_doxygen && ./populate-js-test-data.py && git diff --color=always . | cat; fi
-  - if [ "$WITH_DOCUMENTATION" == "ON" ]; then cd $TRAVIS_BUILD_DIR/documentation/test_doxygen/js-test-data && git diff-index --exit-code HEAD -- .; fi
+  - if [ "$WITH_DOCUMENTATION" == "ON" ]; then cd $TRAVIS_BUILD_DIR/documentation/test&& ./populate-js-test-data.py && git diff --color=always . | cat; fi
+  - if [ "$WITH_DOCUMENTATION" == "ON" ]; then cd $TRAVIS_BUILD_DIR/documentation/test/js-test-data && git diff-index --exit-code HEAD -- .; fi
 
 # Cache the downloaded doxygen and pybind11
 cache: