From c5d1b82f133dc94b41b37354bae7e2c3882526ae Mon Sep 17 00:00:00 2001 From: Koichi Murase Date: Fri, 23 Sep 2022 13:21:24 +0900 Subject: [PATCH] test: minor fixes for msys * test: ensure a non-empty locale * test (ble/util/readlink): work around msys symlinks * test (ble/util/declare-print-definitions): skip array assignments involing CR in msys * test (ble/util/is-stdin-ready): skip test in the CI msys * main (bind): suppress non-interactive warning in msys --- ble.pp | 6 ++++-- lib/test-main.sh | 11 +++++++++-- lib/test-util.sh | 7 ++++++- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/ble.pp b/ble.pp index 39b2a62d..5035df54 100644 --- a/ble.pp +++ b/ble.pp @@ -541,8 +541,8 @@ function ble/base/recover-bash-options { # WA #D1534 workaround for msys2 .inputrc if [[ $OSTYPE == msys* ]]; then - [[ $(builtin bind -m emacs -p | grep '"\\C-?"') == '"\C-?": backward-kill-line' ]] && - builtin bind -m emacs '"\C-?": backward-delete-char' + [[ $(builtin bind -m emacs -p 2>/dev/null | grep '"\\C-?"') == '"\C-?": backward-kill-line' ]] && + builtin bind -m emacs '"\C-?": backward-delete-char' 2>/dev/null fi if [[ ! -o emacs && ! -o vi && ! $_ble_init_command ]]; then @@ -2171,6 +2171,8 @@ function ble/base/process-blesh-arguments { function ble/base/sub:test { local error= logfile= + [[ ${LANG-} ]] || local LANG=en_US.UTF-8 + ble-import lib/core-test if (($#==0)); then diff --git a/lib/test-main.sh b/lib/test-main.sh index 47edde64..2cfe5eb3 100644 --- a/lib/test-main.sh +++ b/lib/test-main.sh @@ -30,6 +30,11 @@ ble/test/start-section 'ble/main' 19 # ble/util/readlink ( + if [[ $OSTYPE == msys* ]]; then + ble/path#append MSYS winsymlinks + export MSYS + fi + ble/bin/.freeze-utility-path readlink ls function ble/test:readlink.impl1 { ret=$1 @@ -56,10 +61,12 @@ ble/test/start-section 'ble/main' 19 ret="${PWD%/}/ab/cd/ef/file.txt" # loop symbolic links + touch loop1.sh ln -s loop1.sh loop0.sh - ln -s loop2.sh loop1.sh - ln -s loop3.sh loop2.sh ln -s loop1.sh loop3.sh + rm loop1.sh + ln -s loop3.sh loop2.sh + ln -s loop2.sh loop1.sh for impl in impl1 impl2; do ble/test "ble/test:readlink.$impl loop0.sh" ret='loop1.sh' done diff --git a/lib/test-util.sh b/lib/test-util.sh index 02fc0a1a..cffd77eb 100644 --- a/lib/test-util.sh +++ b/lib/test-util.sh @@ -1414,7 +1414,8 @@ function is-global() (readonly "$1"; ! local "$1" 2>/dev/null) if ((_ble_bash>=40000)); then ( ble/test 'echo 1 | { sleep 0.01; ble/util/is-stdin-ready; }' - ble/test 'sleep 0.01 | ble/util/is-stdin-ready' exit=1 + [[ ${CI-} == true && ${GITHUB_ACTION-} && $OSTYPE == msys* ]] || + ble/test 'sleep 0.01 | ble/util/is-stdin-ready' exit=1 ble/test 'ble/util/is-stdin-ready <<< a' ble/test 'ble/util/is-stdin-ready <<< ""' @@ -1515,6 +1516,10 @@ ble/test ble/util/is-running-in-subshell exit=1 ble/util/declare-print-definitions a0 a1 a{2..8} 2>/dev/null)" for name in a0 a1 a{2..8}; do + # WA: msys bash では何故か配列代入形式 arr2=("${arr1[@]}") で要素に含まれる + # \r が全て消滅する。仕方がないのでスキップする。 + [[ $name == a5 && $OSTYPE == msys* ]] && continue + stdout_var=s$name ble/test "status $name" ret="${!stdout_var}" done