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

123 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 a 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# - Fix bug where <table><caption> isn't allowed
15
16# - Put all tests in CI
17# - maybe just pip install markdown-it
18#
19# Oils STDLIB:
20#
21# - task-five needs support for proc!
22# - we might need to discover procs differently
23# - right now we're using _bash-print-funcs, which uses shopt -s extdebug,
24#
25# task files
26# - OSH should support shopt -s extdebug! So it can run our task files
27# - always use bash, never use awk/gawk to parse compgen -F
28# - we don't need to worry about awk FS space/tab
29# - if the filename contains newlines, then we are kinda screwed, but we can
30# detect that with bash regex I think - every line must have 3 fields
31# - well I also wanted docstrings, but I think that can be an OSH/YSH-only
32# feature, not a bash feature.
33# - Oils can used for bash completion when necessary
34#
35# - my own bash completion needs to discover procs via the BYO protocol
36# - for doctools/ul-table-test.ysh <TAB>
37#
38# - Use 'byo test' - does that mean byo-server-lib also needs to be YSH?
39
40source $LIB_OSH/task-five.sh
41#source $LIB_YSH/yblocks.ysh
42
43proc run-py {
44 ### Run with the shebang setting
45 PYTHONPATH='.:vendor/' @ARGV
46}
47
48proc run-py3 {
49 PYTHONPATH='.' python3 @ARGV
50}
51
52deps() {
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?
59proc test-unit-py2 {
60 # like test/unit.sh
61 run-py doctools/ul_table_test.py
62}
63
64test-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
70test-unit-py3() {
71 # like test/unit.sh
72 run-py3 doctools/ul_table_test.py
73}
74
75# Taken from unit test
76# TODO: need YSH syntax highlighting of '''
77const TD_ATTRS = '''
78<table>
79
80- thead
81 - <cell-attrs class=unquoted /> name
82 - <cell-attrs class=quoted /> age
83 - role
84- tr <!-- comment --> <!-- comment 2 -->
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
96const CMARK_DIR = '/wedge/oils-for-unix.org/pkg/cmark/0.29.0'
97
98proc cmark-bin {
99 $CMARK_DIR/bin/cmark @ARGV
100}
101
102test-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
111test-without-cmark-py3() {
112 echo $TD_ATTRS | cmark-bin --unsafe | run-py3 doctools/ul_table.py
113}
114
115proc run-tests() {
116 devtools/byo.sh test $0
117}
118
119proc soil-run {
120 echo TODO
121}
122
123task-five "$@"