From add6825898e101ccab12d3ffd93091fc2284e637 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Fri, 29 Jul 2016 19:02:40 +0000 Subject: [PATCH] dev tools: Extend tests/generate.zsh. --- tests/README.md | 12 ++++-------- tests/generate.zsh | 10 +++++++--- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/README.md b/tests/README.md index b7e3450..5526612 100644 --- a/tests/README.md +++ b/tests/README.md @@ -45,17 +45,13 @@ Writing new tests An experimental tool is available to generate test files: - zsh -f tests/generate.zsh 'ls -x' \ - | sed s/YYYY/$(date +%Y)/ \ - > highlighters/main/test-data/foo.zsh - git add -N $_ + zsh -f tests/generate.zsh 'ls -x' acme newfile -This generates a test file based on the current highlighting of the given `$BUFFER` -(in this case, `ls -x`). +This generates a `highlighters/acme/test-data/newfile.zsh` test file based on +the current highlighting of the given `$BUFFER` (in this case, `ls -x`). _This tool is experimental._ Its interface may change. In particular it may -grow ways to set `$PREBUFFER` and/or `$ZSH_HIGHLIGHT_HIGHLIGHTERS` or to -inject free-form code into the generated file. +grow ways to set `$PREBUFFER` to inject free-form code into the generated file. Highlighting test diff --git a/tests/generate.zsh b/tests/generate.zsh index 3fc0ebc..5bd0b60 100755 --- a/tests/generate.zsh +++ b/tests/generate.zsh @@ -31,13 +31,17 @@ emulate -LR zsh # Argument parsing. -if (( $# != 1 )) || [[ $1 == -* ]]; then - print -r -- >&2 "$0: usage: $0 BUFFER" +if (( $# != 3 )) || [[ $1 == -* ]]; then + print -r -- >&2 "$0: usage: $0 BUFFER HIGHLIGHTER BASENAME" 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 fi 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. . ${0:A:h:h}/zsh-syntax-highlighting.zsh