Skip to content

Commit

Permalink
test(bash): fix test cases for history expansion
Browse files Browse the repository at this point in the history
  • Loading branch information
akinomyoga committed Jan 31, 2024
1 parent f9b9aea commit 838b465
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 13 deletions.
13 changes: 7 additions & 6 deletions docs/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
- keymap/vi: implement text-object in xmap for brackets (requested by Darukutsu) `#D2095` 7d80167c
- util: support `ble-import -C callback` (motivated by Dominiquini) `#D2102` 0fdbe3b0
- mandb: look for git subcommands (motivated by bkerin) `#D2112` 9641c3b8
- edit (`display-shell-version`): show the `atuin` version `#D2124` xxxxxxxx
- edit (`display-shell-version`): show the `atuin` version `#D2124` 9045fb87
- complete: add widgets `auto_complete/insert-?word` (requested by Tommimon) `#D2127` xxxxxxxx

## Changes
Expand All @@ -30,7 +30,7 @@
- make: add `INSDIR_LICENSE` for install location of licenses (reported by willemw) `#D2064` d39998f0 acf3b091
- prompt: show prompt ruler after markers (motivated by U-Labs) `#D2067` e4a90378
- complete: suffix a space to non-filenames with `compopt -o filenames` (reported by Dominiquini) `#D2096` aef8927f
- edit: distinguish space and delimiters in `cword` and `eword` `#D2121` xxxxxxxx
- edit: distinguish space and delimiters in `cword` and `eword` `#D2121` 4f453710

## Fixes

Expand All @@ -56,7 +56,7 @@
- edit(gexec): fix a bug that `LINENO` is vanishing `#D2108` b5776596
- mandb: fix extraction of option description in format 5 (reported by bkerin) `#D2110` 90a992cc
- decode: fix handling of @ESC in quoted-insert `#D2119` 0bbc3639
- syntax: save stat after command name for consistent completion-context `#D2126` xxxxxxxx
- syntax: save stat after command name for consistent completion-context `#D2126` 50d6f1bb
- term: fix control sequences for hiding cursor (reported by n87) `#D3230` xxxxxxxx

## Compatibility
Expand Down Expand Up @@ -87,7 +87,7 @@
- progcomp: work around slow `make` completion in large repository (reported by blackteahamburger) `#D2117` 5f3a0010
- util(TRAPEXIT): fix condition for `stty sane` in Cygwin `#D2118` a7f604e1
- progcomp: fix the detection of the zoxide completion (reported by 6801318d8d) `#D2120` 29cd8f10
- progcomp: pass original command path to completion functions (reported by REmerald) `#D2125` xxxxxxxx
- progcomp: pass original command path to completion functions (reported by REmerald) `#D2125` 0cf0383a
- main: work around nRF Connect initialization (requested by liyafe1997) `#D2129` xxxxxxxx

## Contrib
Expand All @@ -113,8 +113,9 @@
- test(main): fix delimiter of `MSYS` in adding `winsymlinks` `#D2071` aacf1462
- test(util,vi): adjust `ble/util/is-stdin-ready` while testing `#D2105` 23a05827 6f4badf4
- test(vi): suppress warnings for non-interactive sessions `#D2113` b8b7ba0c
- test(bash,util): fix tests in interactive session `#D2123` xxxxxxxx
- test(vi): fix broken states after test `#D2123` xxxxxxxx
- test(bash,util): fix tests in interactive session `#D2123` 06ad3a6c
- test(vi): fix broken states after test `#D2123` 06ad3a6c
- test(bash): fix test cases for history expansion `#D2131` xxxxxxxx

## Internal changes

Expand Down
18 changes: 11 additions & 7 deletions lib/test-bash.sh
Original file line number Diff line number Diff line change
Expand Up @@ -333,18 +333,22 @@ ble/test/start-section 'bash' 49
# いが微妙に異なることを議論している。
#
q=\' line='$'$q'\'$q'!!'$q'\'$q
ble/util/assign ret '(builtin history -s histentry; builtin history -p "$line")'
code='(builtin history -s histentry; builtin history -p "$line")'
if ((_ble_bash<30100)); then
# 3.0 ではそもそも失敗する。
ble/test code:'' ret=
ble/test "$code" stdout=
elif ((_ble_bash<40100)) || [[ $- != *[iH]* ]]; then
# 非対話セッション または 3.1..4.0 では意図せず展開が起こる
ble/test code:'' ret="${line//!!/histentry}"
ble/test "$code" stdout="${line//!!/histentry}"
else
# 期待した振る舞い
ble/test code:'' ret="$line"
ble/test "$code" stdout="$line"
fi
if ((_ble_bash<40100)); then
ble/test '(set -H; builtin history -c; builtin history -p "$line")' stdout= exit=1
else
ble/test '(set -H; builtin history -c; builtin history -p "$line")' stdout="$line"
fi
ble/test '(set -H; builtin history -c; builtin history -p "$line")' stdout="$line"

# BUG bash-3.0 [Ref #D1956]
# 関数定義の一番外側でリダイレクトしてもリダイレクトされない。例えば、
Expand Down Expand Up @@ -376,7 +380,7 @@ ble/test/start-section 'bash' 49
# (#D2123) In all the Bash versions 1.14..5.3, expand_aliases inside
# "compond-command &" are disabled in interactive sessions.
shopt -s expand_aliases
alias e='echo hello'
alias e='ble/util/print hello'
ble/test 'eval "e"' stdout=hello
ble/test 'true && eval "e"' stdout=hello
ble/test 'eval "e" & wait' stdout=hello
Expand All @@ -389,7 +393,7 @@ ble/test/start-section 'bash' 49
ble/test '{ eval "e"; } & wait' stdout=hello
ble/test 'true && eval "e" & wait' stdout=hello
fi
unalias e
builtin unalias e
)

ble/test/end-section
11 changes: 11 additions & 0 deletions note.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7071,6 +7071,17 @@ bash_tips
Done (実装ログ)
-------------------------------------------------------------------------------

2024-02-01

* test: bash-3.2 での test-bash.sh が CI で失敗している [#D2131]

macOS で失敗している。新しく追加したテストは bash version に依存する気がす
る。どうやら履歴展開に失敗した時に元の文字列を返すのは bash-4.1 以降の話の
様である。

make scan すると新しいテスト項目に対しても何件か警告が出ているのでそれも修
正する。これらは既に push してしまっているので元の commit には含められない。

2024-01-31

* term: カーソルが設定していないのに点滅する (reported by n87) [#D2130]
Expand Down

0 comments on commit 838b465

Please sign in to comment.