Mercurial > evolve
changeset 5373:ce5ebd9c859b
tests: add a test determining the branch and topic like the Zsh prompt does it
A patch was sent to the Zsh developers to change the prompt to include the name
of the topic if it is set. It was agreed that I submit a test case to the topic
extension that fails if the format of the files used by Zsh changes.
The current version of the patch can be found here:
https://www.zsh.org/mla/workers/2020/msg00910.html
author | Manuel Jacob <me@manueljacob.de> |
---|---|
date | Mon, 22 Jun 2020 01:03:22 +0200 |
parents | 02804d8bac31 |
children | 6f7a2dcc8c7a |
files | tests/test-topic-shell-prompt.t |
diffstat | 1 files changed, 29 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-topic-shell-prompt.t Mon Jun 22 01:03:22 2020 +0200 @@ -0,0 +1,29 @@ + $ . $TESTDIR/testlib/topic_setup.sh + +Code logically equivalent to the following is used in Zsh to show the branch +and topic (if set) in the prompt. If the format of the files is changed in a +way that it breaks the test, a mail should be sent to zsh-workers@zsh.org. + + $ get_branch_like_zsh() { + > branchfile=".hg/branch" + > topicfile=".hg/topic" + > if [ -r "${branchfile}" ] ; then + > r_branch=$(cat "${branchfile}") + > fi + > if [ -f "${topicfile}" ] && [ -r "${topicfile}" ] && [ -s "${topicfile}" ] ; then + > IFS= read -r REPLY < ${topicfile} + > r_branch=${r_branch}:${REPLY} + > fi + > echo $r_branch + > } + + $ hg init + $ hg branch branch -q + $ get_branch_like_zsh + branch + $ hg topic topic -q + $ get_branch_like_zsh + branch:topic + $ hg topic --clear -q + $ get_branch_like_zsh + branch