Skip to content

test(conftest): exclude cache variables for diff_env #798

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions test/config/bashrc
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,22 @@ add_comp_wordbreak_char()
[[ "${COMP_WORDBREAKS//[^$1]/}" ]] || COMP_WORDBREAKS+=$1
}

_comp__test_get_env()
{
(
# Do not output the state of test variables "_comp__test_+([0-9])_*"
# and internal mutable variables "_comp_*_mut_*".
# shellcheck disable=SC2046
unset -v $(compgen -W '"${!_comp_@}"' -X '!_comp_@(_test_+([0-9])_*|*_mut_*)')

set -o posix
set
)
declare -F
shopt -p
set -o
}

# Local variables:
# mode: shell-script
# End:
Expand Down
4 changes: 2 additions & 2 deletions test/t/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ def get_env(bash: pexpect.spawn) -> List[str]:
x
for x in assert_bash_exec(
bash,
"{ (set -o posix ; set); declare -F; shopt -p; set -o; }",
"_comp__test_get_env",
want_output=True,
)
.strip()
Expand All @@ -728,7 +728,7 @@ def diff_env(before: List[str], after: List[str], ignore: str):
if not re.search(r"^(---|\+\+\+|@@ )", x)
# Ignore variables expected to change:
and not re.search(
r"^[-+](_|PPID|BASH_REMATCH|_comp__test_\d+_\w+)=",
r"^[-+](_|PPID|BASH_REMATCH|(BASH_)?LINENO)=",
x,
re.ASCII,
)
Expand Down