diff --git a/src/commands.cc b/src/commands.cc index 6edc308b..f2cb1c33 100644 --- a/src/commands.cc +++ b/src/commands.cc @@ -1449,6 +1449,7 @@ const CommandDesc echo_cmd = { ParameterDesc{ { { "markup", { {}, "parse markup" } }, { "quoting", { {arg_completer(Array{"raw", "kakoune", "shell"})}, "quote each argument separately using the given style (raw|kakoune|shell)" } }, + { "end-of-line", { {}, "add trailing end-of-line" } }, { "to-file", { {filename_arg_completer}, "echo contents to given filename" } }, { "to-shell-script", { ArgCompleter{}, "pipe contents to given shell script" } }, { "debug", { {}, "write to debug buffer instead of status line" } } }, @@ -1466,6 +1467,9 @@ const CommandDesc echo_cmd = { else message = join(parser, ' ', false); + if (parser.get_switch("end-of-line")) + message.push_back('\n'); + if (auto filename = parser.get_switch("to-file")) write_to_file(*filename, message); else if (auto command = parser.get_switch("to-shell-script")) diff --git a/test/run b/test/run index 751cca40..93b9e5ca 100755 --- a/test/run +++ b/test/run @@ -14,29 +14,26 @@ main() { exec -save-regs / %{%s%\(\K[^)]+\)ai} } catch %{ exec gg } try %{ source rc } - hook global RuntimeError .+ %{ - echo -debug -- error: %val{hook_param} - eval -buffer *debug* write -force debug - quit! - } - try %{ exec -with-maps -with-hooks "%sh{cat cmd}" } + try %{ eval -draft %{ edit cmd; exec \%H"zy; delete-buffer } } + try %{ exec -with-maps -with-hooks %reg{z} } exec -with-hooks ' root=$PWD tmpdir="${TMPDIR:-/tmp}" work=$(mktemp -d $tmpdir/kak-tests.XXXXXXXX) + session="kak-tests" + if [ -n "$XDG_RUNTIME_DIR" ]; then + session_path="${XDG_RUNTIME_DIR}/kakoune/$session" + else + session_path="${TMPDIR:-/tmp}/kakoune/${USER}/$session" + fi trap "rm -R $work" EXIT number_tests=0 number_failures=0 for dir in $(find "${@:-.}" -type d | sort); do cd $root/$dir; - mkdir -p $work/$dir - for file in in cmd rc enabled; do - [ -f $file ] && cp $file $work/$dir/ - done - cd $work/$dir; indent="$(echo "$dir/" | sed -e 's|[^/]*//*| |g')" name=${PWD##*/} if [ ! -f cmd ]; then @@ -47,13 +44,15 @@ main() { continue fi - env_vars=$(cd "${root}/${dir}" && ls -1 kak_* 2>/dev/null) + env_vars=$(ls -1 kak_* 2>/dev/null) + number_tests=$(($number_tests + 1)) + mkdir -p $work/$dir + cp in cmd rc $work/$dir/ 2>/dev/null + cd $work/$dir; mkfifo ui-in ui-out - number_tests=$(($number_tests + 1)) touch in; cp in out - session="kak-tests" - rm -f "$(session_path $session)" + rm -f "$session_path" $DEBUGGER $root/../src/kak out -n -s "$session" -ui json -e "$kak_commands" >ui-out %s\n' "$env_var" "$env_var" + case $env_var in + kak_quoted_*) printf 'echo -to-file %s -end-of-line -quoting shell -- %s\n' "$env_var" "%val{${env_var##kak_quoted_}}" ;; + kak_*) printf 'echo -to-file %s -end-of-line -- %s\n' "$env_var" "%val{${env_var##kak_}}" ;; + esac done - printf %s ' } + printf %s ' write -force out quit! }