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