1 | #!bin/ysh
|
2 | #
|
3 | # System tests for ul-table.
|
4 | #
|
5 | # Usage:
|
6 | # doctools/ul-table-test.ysh <function name>
|
7 |
|
8 | # TODO:
|
9 | #
|
10 | # - another pass over ul_table doc
|
11 | #
|
12 | # - Run with another markdown processor other than cmark? pandoc?
|
13 | # - Because markdown.pl doesn't support the inline HTML rule
|
14 | # - markdown-it-py - https://github.com/executablebooks/markdown-it-py?tab=readme-ov-file
|
15 | #
|
16 | # - task-five needs support for proc!
|
17 | # - we might need to discover procs differently
|
18 | # - right now we're using _bash-print-funcs, which uses shopt -s extdebug,
|
19 | #
|
20 | # task files
|
21 | # - OSH should support shopt -s extdebug! So it can run our task files
|
22 | # - always use bash, never use awk/gawk to parse compgen -F
|
23 | # - we don't need to worry about awk FS space/tab
|
24 | # - if the filename contains newlines, then we are kinda screwed, but we can
|
25 | # detect that with bash regex I think - every line must have 3 fields
|
26 | # - well I also wanted docstrings, but I think that can be an OSH/YSH-only
|
27 | # feature, not a bash feature.
|
28 | # - Oils can used for bash completion when necessary
|
29 | #
|
30 | # - my own bash completion needs to discover procs via the BYO protocol
|
31 | #
|
32 | # - Use 'byo test' - does that mean byo-server-lib also needs to be YSH?
|
33 | #
|
34 | # - Put all tests in CI
|
35 | # - maybe just pip install markdown-it
|
36 | #
|
37 | # - lazylex/html.py
|
38 | # - fix the lexer and make it data_lang/htm8.py?
|
39 | #
|
40 | # - might want to run it through pyannotate too?
|
41 | # - python2/python3 conflicts with mycpp distribution though
|
42 | # - mylib.BufWriter() is different than cStringIo.StringIO aka io.StringIO
|
43 | # - see {types,asdl}/pyann_driver.py
|
44 |
|
45 | source $LIB_OSH/task-five.sh
|
46 | #source $LIB_YSH/yblocks.ysh
|
47 |
|
48 | proc run-py {
|
49 | PYTHONPATH='.:vendor/' @ARGV
|
50 | }
|
51 |
|
52 | deps() {
|
53 | # Good: only 3 files: ul_table, lazylex/html, util.py
|
54 | build/dynamic-deps.sh py-tool doctools.ul_table
|
55 | }
|
56 |
|
57 | # proc doesn't work with task-five!
|
58 | # we need task-five.ysh?
|
59 | proc test-unit-py2 {
|
60 | # like test/unit.sh
|
61 | run-py doctools/ul_table_test.py
|
62 | }
|
63 |
|
64 | test-unit-py2() {
|
65 | # like test/unit.sh
|
66 | run-py doctools/ul_table_test.py
|
67 | }
|
68 |
|
69 | # Problem: We import cmark, which imports ctypes
|
70 | test-unit-py3() {
|
71 | # like test/unit.sh
|
72 | run-py python3 doctools/ul_table_test.py
|
73 | }
|
74 |
|
75 | # Taken from unit test
|
76 | # TODO: need YSH syntax highlighting of '''
|
77 | const TD_ATTRS = '''
|
78 | <table>
|
79 |
|
80 | - thead
|
81 | - <cell-attrs class=unquoted /> name
|
82 | - <cell-attrs class=quoted /> age
|
83 | - role
|
84 | - tr
|
85 | - <cell-attrs class="cool" /> alice
|
86 | - 30
|
87 | - parent
|
88 | - tr
|
89 | - bob
|
90 | - 42
|
91 | - <cell-attrs class=child /> child
|
92 |
|
93 | </table>
|
94 | '''
|
95 |
|
96 | const CMARK_DIR = '/wedge/oils-for-unix.org/pkg/cmark/0.29.0'
|
97 |
|
98 | proc cmark-bin {
|
99 | $CMARK_DIR/bin/cmark @ARGV
|
100 | }
|
101 |
|
102 | test-without-cmark-py2() {
|
103 | # Oh markdown.pl doesn't have the embedded HTML rule?
|
104 |
|
105 | # cmark omits raw HTML by default
|
106 | # cmark-bin --help
|
107 |
|
108 | echo $TD_ATTRS | cmark-bin --unsafe | run-py doctools/ul_table.py
|
109 | }
|
110 |
|
111 | test-without-cmark-py3() {
|
112 | echo $TD_ATTRS | cmark-bin --unsafe | run-py python3 doctools/ul_table.py
|
113 | }
|
114 |
|
115 | proc run-tests() {
|
116 | devtools/byo.sh test $0
|
117 | }
|
118 |
|
119 | proc soil-run {
|
120 | echo TODO
|
121 | }
|
122 |
|
123 | task-five "$@"
|