OILS / doctools / ul-table-test.ysh View on Github | oils.pub

135 lines, 37 significant
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
52source $LIB_OSH/task-five.sh
53#source $LIB_YSH/yblocks.ysh
54
55proc run-py {
56 ### Run with the shebang setting
57 PYTHONPATH='.:vendor/' @ARGV
58}
59
60proc run-py3 {
61 PYTHONPATH='.' python3 @ARGV
62}
63
64deps() {
65 # Good: only 3 files: ul_table, lazylex/html, util.py
66 build/dynamic-deps.sh py-tool doctools.ul_table
67}
68
69# proc doesn't work with task-five!
70# we need task-five.ysh?
71proc test-unit-py2 {
72 # like test/unit.sh
73 run-py doctools/ul_table_test.py
74}
75
76test-unit-py2() {
77 # like test/unit.sh
78 run-py doctools/ul_table_test.py
79}
80
81# Problem: We import cmark, which imports ctypes
82test-unit-py3() {
83 # like test/unit.sh
84 run-py3 doctools/ul_table_test.py
85}
86
87# Taken from unit test
88# TODO: need YSH syntax highlighting of '''
89const TD_ATTRS = '''
90<table>
91
92- thead
93 - <cell-attrs class=unquoted /> name
94 - <cell-attrs class=quoted /> age
95 - role
96- tr <!-- comment --> <!-- comment 2 -->
97 - <cell-attrs class="cool" /> alice
98 - 30
99 - parent
100- tr
101 - bob
102 - 42
103 - <cell-attrs class=child /> child
104
105</table>
106'''
107
108const CMARK_DIR = '/wedge/oils-for-unix.org/pkg/cmark/0.29.0'
109
110proc cmark-bin {
111 $CMARK_DIR/bin/cmark @ARGV
112}
113
114test-without-cmark-py2() {
115 # Oh markdown.pl doesn't have the embedded HTML rule?
116
117 # cmark omits raw HTML by default
118 # cmark-bin --help
119
120 echo $TD_ATTRS | cmark-bin --unsafe | run-py doctools/ul_table.py
121}
122
123test-without-cmark-py3() {
124 echo $TD_ATTRS | cmark-bin --unsafe | run-py3 doctools/ul_table.py
125}
126
127proc run-tests() {
128 devtools/byo.sh test $0
129}
130
131proc soil-run {
132 echo TODO
133}
134
135task-five "$@"