dev tools: Extend tests/generate.zsh.
This commit is contained in:
		
							parent
							
								
									8013dc3b8d
								
							
						
					
					
						commit
						add6825898
					
				|  | @ -45,17 +45,13 @@ Writing new tests | ||||||
| 
 | 
 | ||||||
| An experimental tool is available to generate test files: | An experimental tool is available to generate test files: | ||||||
| 
 | 
 | ||||||
|     zsh -f tests/generate.zsh 'ls -x' \ |     zsh -f tests/generate.zsh 'ls -x' acme newfile | ||||||
|       | sed s/YYYY/$(date +%Y)/ \ |  | ||||||
|       > highlighters/main/test-data/foo.zsh |  | ||||||
|     git add -N $_ |  | ||||||
| 
 | 
 | ||||||
| This generates a test file based on the current highlighting of the given `$BUFFER` | This generates a `highlighters/acme/test-data/newfile.zsh` test file based on | ||||||
| (in this case, `ls -x`). | the current highlighting of the given `$BUFFER` (in this case, `ls -x`). | ||||||
| 
 | 
 | ||||||
| _This tool is experimental._  Its interface may change.  In particular it may | _This tool is experimental._  Its interface may change.  In particular it may | ||||||
| grow ways to set `$PREBUFFER` and/or `$ZSH_HIGHLIGHT_HIGHLIGHTERS` or to | grow ways to set `$PREBUFFER` to inject free-form code into the generated file. | ||||||
| inject free-form code into the generated file. |  | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| Highlighting test | Highlighting test | ||||||
|  |  | ||||||
|  | @ -31,13 +31,17 @@ | ||||||
| emulate -LR zsh | emulate -LR zsh | ||||||
| 
 | 
 | ||||||
| # Argument parsing. | # Argument parsing. | ||||||
| if (( $# != 1 )) || [[ $1 == -* ]]; then | if (( $# != 3 )) || [[ $1 == -* ]]; then | ||||||
|   print -r -- >&2 "$0: usage: $0 BUFFER" |   print -r -- >&2 "$0: usage: $0 BUFFER HIGHLIGHTER BASENAME" | ||||||
|   print -r -- >&2 "" |   print -r -- >&2 "" | ||||||
|   print -r -- >&2 "This tool generates a test file, suitable for highlighters/*/test-data/." |   print -r -- >&2 "Generate highlighters/HIGHILGHTER/test-data/BASENAME.zsh based on the" | ||||||
|  |   print -r -- >&2 "current highlighting of BUFFER." | ||||||
|   exit 1 |   exit 1 | ||||||
| fi | fi | ||||||
| buffer=$1 | buffer=$1 | ||||||
|  | ZSH_HIGHLIGHT_HIGHLIGHTERS=( $2 ) | ||||||
|  | exec >${0:A:h:h}/highlighters/$2/test-data/$3.zsh | ||||||
|  | git add -N ${0:A:h:h}/highlighters/$2/test-data/$3.zsh | ||||||
| 
 | 
 | ||||||
| # Load the main script. | # Load the main script. | ||||||
| . ${0:A:h:h}/zsh-syntax-highlighting.zsh | . ${0:A:h:h}/zsh-syntax-highlighting.zsh | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue