Skip to content

Commit

Permalink
tests: HTML-escape tabs
Browse files Browse the repository at this point in the history
Simplifies copying diff output from most terminal programs, where tab character is treated not as a character to display, but as an instruction to move the cursor.
  • Loading branch information
laniakea64 committed Jun 14, 2024
1 parent 045a196 commit 6858181
Show file tree
Hide file tree
Showing 10 changed files with 165 additions and 163 deletions.
2 changes: 1 addition & 1 deletion tests/cases/import.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<span class="Include">import</span><span class="Special">\</span>
<span class="String">'line-continuations.just'</span>

<span class="Include">import</span> <span class="Conditional">?</span> <span class="String">"""</span>
<span class="Include">import</span> <span class="Conditional">?</span>&Tab;<span class="String">"""</span>
<span class="String"> tricky.just"""</span>

<span class="Include">import</span><span class="Conditional">?</span> <span class="String">x'</span><span class="PreProc">${FOOOOOOOOO</span><span class="Operator">:-</span><span class="Character">.</span><span class="PreProc">}</span><span class="String">/foo.just'</span>
Expand Down
74 changes: 37 additions & 37 deletions tests/cases/invalid.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,98 +12,98 @@
<span class="Comment"># just thinks the following line is a malformed attempt to start a recipe called "export"</span>
<span class="Function">export</span> <span class="Identifier">FOO</span>

(the next line is not a recipe body)...
this text should not be highlighted
&Tab;(the next line is not a recipe body)...
&Tab;this text should not be highlighted

badfunc5 <span class="Operator">:=</span> <span class="Function">num_cpus</span>(\)

not_a_recipe_name <span class="Comment">#comment:</span>
not a recipe body
&Tab;not a recipe body

nonexistant_func <span class="Operator">:=</span> blahuuid()
nonexistant_func2 <span class="Operator">:=</span> blah_replace_regex(<span class="String">'foo'</span>, <span class="String">'([^o])'</span>, <span class="String">'$1'</span>)

<span class="Function">invalid_recipe_body</span><span class="Operator">:</span>
<span class="Error"> </span>echo <span class="String">'My indentation mixes spaces and tabs!'</span>
<span class="Error"> </span>echo <span class="String">'My indentation mixes tabs and spaces!'</span>
<span class="Error"> </span>echo <span class="String">'Mixing spaces and tabs again.'</span>
<span class="Error">&Tab; </span>echo <span class="String">'My indentation mixes spaces and tabs!'</span>
&Tab;<span class="Error"> </span>echo <span class="String">'My indentation mixes tabs and spaces!'</span>
<span class="Error">&Tab;</span>echo <span class="String">'Mixing spaces and tabs again.'</span>

<span class="Function">invalid_recipe_body2</span><span class="Operator">:</span>
<span class="Number"> echo This line is valid</span>
<span class="Number"> </span><span class="Error"> </span><span class="Number">echo but this one is not</span>
<span class="Number">&Tab;echo This line is valid</span>
<span class="Number">&Tab;</span><span class="Error"> </span><span class="Number">echo but this one is not</span>
<span class="Function">invalid_recipe_body3</span><span class="Operator">:</span>
<span class="Number"> echo </span><span class="String">"valid again</span>
<span class="String"> </span><span class="Error"> </span><span class="String">not valid"</span>
<span class="Number">&Tab;echo </span><span class="String">"valid again</span>
<span class="String">&Tab;</span><span class="Error"> </span><span class="String">not valid"</span>
<span class="Function">invalid_recipe_body4</span><span class="Operator">:</span>
<span class="Number"> echo </span><span class="String">'valid again</span>
<span class="String"> </span><span class="Error"> </span><span class="String">not valid'</span>
<span class="String"> </span><span class="Error">&Tab;</span><span class="String">not valid'</span>

not_a_recipe_start
not a recipe body
&Tab;not a recipe body
<span class="Function">bad_but_not_mixed_indentation</span><span class="Operator">:</span>
<span class="Number"> echo </span><span class="String">'tab indent'</span>
<span class="Number">&Tab;echo </span><span class="String">'tab indent'</span>
echo <span class="String">'space indent'</span>
<span class="Function">bad_but_not_mixed_indentation_shebang</span><span class="Operator">:</span>
<span class="Number"> </span><span class="SpecialComment">#!/bin/bash</span>
<span class="Number"> echo </span><span class="String">'space indent, same as first line'</span>
<span class="Number"> echo </span><span class="String">'acceptable space indent'</span>
echo <span class="String">'tab indent'</span>
&Tab;echo <span class="String">'tab indent'</span>

<span class="Function">bad_curly_braces</span><span class="Operator">:</span>
<span class="Number"> echo </span><span class="Error">{{{</span><span class="Number">Odd number of opening curly braces is an error.}}</span>
<span class="Number"> echo </span><span class="Error">{{{{{</span><span class="Number">Odd number of opening curly braces is an error.}}</span>
<span class="Number"> echo </span><span class="Special">{{{{</span><span class="Error">{{{</span><span class="Number">Odd number of opening curly braces is an error.}}</span>
<span class="Number"> echo </span><span class="Special">{{{{</span><span class="Error">{{{{{</span><span class="Number">Odd number of opening curly braces is an error.}}</span>
<span class="Number"> echo </span><span class="String">'</span><span class="Error">{{{</span><span class="String">Odd number of opening curly braces is an error.}}'</span>
<span class="Number"> echo </span><span class="String">'</span><span class="Error">{{{{{</span><span class="String">Odd number of opening curly braces is an error.}}'</span>
<span class="Number"> echo </span><span class="String">'</span><span class="Special">{{{{</span><span class="Error">{{{</span><span class="String">Odd number of opening curly braces is an error.}}'</span>
<span class="Number"> echo </span><span class="String">'</span><span class="Special">{{{{</span><span class="Error">{{{{{</span><span class="String">Odd number of opening curly braces is an error.}}'</span>
<span class="Number"> echo </span><span class="Special">{{{{</span><span class="Error">{{{</span><span class="Number">Odd number of opening curly braces is an error.}}}}}</span>
<span class="Number"> echo </span><span class="String">"</span><span class="Special">{{{{</span><span class="Error">{{{{{</span><span class="String">Odd number of opening curly braces is an error.}}}}}"</span>
<span class="Number">&Tab;echo </span><span class="Error">{{{</span><span class="Number">Odd number of opening curly braces is an error.}}</span>
<span class="Number">&Tab;echo </span><span class="Error">{{{{{</span><span class="Number">Odd number of opening curly braces is an error.}}</span>
<span class="Number">&Tab;echo </span><span class="Special">{{{{</span><span class="Error">{{{</span><span class="Number">Odd number of opening curly braces is an error.}}</span>
<span class="Number">&Tab;echo </span><span class="Special">{{{{</span><span class="Error">{{{{{</span><span class="Number">Odd number of opening curly braces is an error.}}</span>
<span class="Number">&Tab;echo </span><span class="String">'</span><span class="Error">{{{</span><span class="String">Odd number of opening curly braces is an error.}}'</span>
<span class="Number">&Tab;echo </span><span class="String">'</span><span class="Error">{{{{{</span><span class="String">Odd number of opening curly braces is an error.}}'</span>
<span class="Number">&Tab;echo </span><span class="String">'</span><span class="Special">{{{{</span><span class="Error">{{{</span><span class="String">Odd number of opening curly braces is an error.}}'</span>
<span class="Number">&Tab;echo </span><span class="String">'</span><span class="Special">{{{{</span><span class="Error">{{{{{</span><span class="String">Odd number of opening curly braces is an error.}}'</span>
<span class="Number">&Tab;echo </span><span class="Special">{{{{</span><span class="Error">{{{</span><span class="Number">Odd number of opening curly braces is an error.}}}}}</span>
<span class="Number">&Tab;echo </span><span class="String">"</span><span class="Special">{{{{</span><span class="Error">{{{{{</span><span class="String">Odd number of opening curly braces is an error.}}}}}"</span>

<span class="Function">early-interpolation-close</span> <span class="Identifier">foo</span><span class="Operator">:</span>
<span class="Number"> echo </span><span class="Delimiter">{{</span><span class="Normal"> </span><span class="Conditional">if</span><span class="Normal"> </span><span class="Identifier">foo</span><span class="Normal"> </span><span class="Operator">==</span><span class="Normal"> </span><span class="String">"bar"</span><span class="Normal"> { </span><span class="String">"hello"</span><span class="Normal"> } </span><span class="Conditional">else</span><span class="Normal"> { </span><span class="String">"goodbye"</span><span class="Normal"> </span><span class="Delimiter">}}</span><span class="Number">}</span>
<span class="Function">other-recipe</span><span class="Operator">:</span>
<span class="Number"> echo interpolation ended in last recipe</span>
<span class="Number">&Tab;echo interpolation ended in last recipe</span>

<span class="Function">variadic-env-wrong-order1</span> <span class="Identifier">param0</span> <span class="Error">$*</span><span class="Identifier">PARAM</span><span class="Operator">:</span>
<span class="Number"> env</span>
<span class="Number">&Tab;env</span>
<span class="Function">variadic-env-wrong-order2</span> <span class="Error">$+</span><span class="Identifier">PARAM</span><span class="Operator">=</span><span class="String">"1"</span><span class="Operator">:</span>
<span class="Number"> env</span>
<span class="Number">&Tab;env</span>
<span class="Function">variadic-env-wrong-order-with-whitespace</span> <span class="Error">$ *</span> <span class="Identifier">PARAM</span><span class="Operator">:</span>
<span class="Number"> env</span>
<span class="Number">&Tab;env</span>

<span class="Function">non-default-param-after-default</span> <span class="Identifier">param0</span><span class="Operator">=</span><span class="String">'value'</span> <span class="Error">param1</span><span class="Operator">:</span>
<span class="Number"> /bin/false</span>
<span class="Number">&Tab;/bin/false</span>
<span class="Function">non-default-param-after-default2</span> <span class="Identifier">param0</span><span class="Operator">=</span><span class="String">'value'</span> <span class="Error">* $ PARAM</span><span class="Operator">:</span>
<span class="Number"> env</span>
<span class="Number">&Tab;env</span>
<span class="Function">non-default-param-after-default3</span> <span class="Identifier">param0</span><span class="Operator">=</span><span class="String">'value'</span> <span class="Error">param1</span> <span class="Identifier">param2</span> <span class="Identifier">param3</span> <span class="Identifier">param4</span><span class="Operator">=</span>something <span class="Error">param5</span><span class="Operator">:</span>
<span class="Number"> /bin/false</span>
<span class="Number">&Tab;/bin/false</span>
<span class="Function">non-default-param-after-default4</span> <span class="Identifier">param0</span><span class="Operator">=</span><span class="String">'''</span>
<span class="String">value</span>
<span class="String">'''</span> <span class="Error">param1</span> <span class="Statement">+</span> <span class="Statement">$</span> <span class="Identifier">param2</span><span class="Operator">:</span>
<span class="Number"> env</span>
<span class="Number">&Tab;env</span>

<span class="Type">[confirm</span><span class="Error">()</span><span class="Type">]</span>
<span class="Function">argless-attribute1</span><span class="Operator">:</span>
<span class="Number"> /bin/false</span>
<span class="Number">&Tab;/bin/false</span>

<span class="Type">[confirm</span><span class="Error">( )</span><span class="Type">]</span>
<span class="Function">argless-attribute2</span><span class="Operator">:</span>
<span class="Number"> /bin/false</span>
<span class="Number">&Tab;/bin/false</span>

<span class="Type">[confirm</span> <span class="Special">\</span>
<span class="Error">(</span>
<span class="Error"> </span>
<span class="Error"> \</span>
<span class="Error">)</span> <span class="Type">]</span>
<span class="Function">argless-attribute3</span><span class="Operator">:</span>
<span class="Number"> /bin/false</span>
<span class="Number">&Tab;/bin/false</span>

<span class="Function">invalid_multi_line_interp</span><span class="Operator">:</span>
<span class="Number"> echo </span><span class="Delimiter">{{</span><span class="String">"foo"</span><span class="Normal"> </span><span class="Operator">+</span><span class="Normal"> </span><span class="Special">\</span>
<span class="Number">&Tab;echo </span><span class="Delimiter">{{</span><span class="String">"foo"</span><span class="Normal"> </span><span class="Operator">+</span><span class="Normal"> </span><span class="Special">\</span>
<span class="Error">b</span>ar }}
echo this line is not part of the recipe body
&Tab;echo this line is not part of the recipe body

<span class="Type">[group</span><span class="Operator">:</span> <span class="Error">group</span><span class="Type">]</span>
<span class="Function">invalid-shorthand-attr-value</span><span class="Operator">:</span>
Expand Down
20 changes: 10 additions & 10 deletions tests/cases/kitchen-sink.html
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,15 @@
}

<span class="Function">shebang</span><span class="Operator">:</span>
<span class="Number"> </span><span class="SpecialComment">#!</span><span class="Delimiter">{{</span><span class="Identifier">shebang</span><span class="Delimiter">}}</span>
<span class="Number"> $PSV = $PSVersionTable.PSVersion | % {</span><span class="String">"$_"</span><span class="Number"> -split </span><span class="String">"\."</span><span class="Number"> }</span>
<span class="Number"> $psver = $PSV[0] + </span><span class="String">"."</span><span class="Number"> + $PSV[1]</span>
<span class="Number"> if ($PSV[2].Length -lt 4) {</span>
<span class="Number"> $psver += </span><span class="String">"."</span><span class="Number"> + $PSV[2] + </span><span class="String">" Core"</span>
<span class="Number"> } else {</span>
<span class="Number"> $psver += </span><span class="String">" Desktop"</span>
<span class="Number"> }</span>
<span class="Number"> echo </span><span class="String">"PowerShell $psver"</span>
<span class="Number">&Tab;</span><span class="SpecialComment">#!</span><span class="Delimiter">{{</span><span class="Identifier">shebang</span><span class="Delimiter">}}</span>
<span class="Number">&Tab;$PSV = $PSVersionTable.PSVersion | % {</span><span class="String">"$_"</span><span class="Number"> -split </span><span class="String">"\."</span><span class="Number"> }</span>
<span class="Number">&Tab;$psver = $PSV[0] + </span><span class="String">"."</span><span class="Number"> + $PSV[1]</span>
<span class="Number">&Tab;if ($PSV[2].Length -lt 4) {</span>
<span class="Number">&Tab;&Tab;$psver += </span><span class="String">"."</span><span class="Number"> + $PSV[2] + </span><span class="String">" Core"</span>
<span class="Number">&Tab;} else {</span>
<span class="Number">&Tab;&Tab;$psver += </span><span class="String">" Desktop"</span>
<span class="Number">&Tab;}</span>
<span class="Number">&Tab;echo </span><span class="String">"PowerShell $psver"</span>

<span class="Special">@</span><span class="Function">foo</span><span class="Operator">:</span>
<span class="Number"> echo bar</span>
Expand All @@ -160,7 +160,7 @@


<span class="Function">notify</span> <span class="Identifier">m</span><span class="Operator">=</span><span class="String">""</span><span class="Operator">:</span>
<span class="Number"> keybase chat send --topic-type </span><span class="String">"chat"</span><span class="Number"> --channel &lt;channel&gt; &lt;team&gt; </span><span class="String">"upd(&lt;repo&gt;): </span><span class="Delimiter">{{</span><span class="Identifier">m</span><span class="Delimiter">}}</span><span class="String">"</span>
<span class="Number">&Tab;keybase chat send --topic-type </span><span class="String">"chat"</span><span class="Number"> --channel &lt;channel&gt; &lt;team&gt; </span><span class="String">"upd(&lt;repo&gt;): </span><span class="Delimiter">{{</span><span class="Identifier">m</span><span class="Delimiter">}}</span><span class="String">"</span>

<span class="Comment"># Sample project script 2</span>
<span class="Function">script2</span> <span class="Statement">*</span><span class="Identifier">ARGS</span><span class="Operator">:</span>
Expand Down
Loading

0 comments on commit 6858181

Please sign in to comment.