Skip to content

Commit f4e7425

Browse files
committed
Fix tests; allow output checking with wildcards
1 parent 4de2bf0 commit f4e7425

File tree

4 files changed

+30
-6
lines changed

4 files changed

+30
-6
lines changed

bin/pyenv-virtualenv

+7-1
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,13 @@ STATUS=0
605605
mkdir -p "${PYENV_VIRTUALENV_CACHE_PATH}"
606606
cd "${PYENV_VIRTUALENV_CACHE_PATH}"
607607
if [ -n "${USE_CONDA}" ]; then
608-
pyenv-exec conda create $QUIET $VERBOSE --name "${VIRTUALENV_PATH##*/}" --yes "${VIRTUALENV_OPTIONS[@]}" --file <(pyenv-exec conda list python --full-name --export) || STATUS="$?"
608+
if [ -z "$VIRTUALENV_PYTHON" ]; then
609+
#process substitution doesn't seem to work unless it's directly inserted to the command line
610+
#if we add it to VIRTUALENV_OPTIONS instead, "broken pipe" happens
611+
pyenv-exec conda create $QUIET $VERBOSE --name "${VIRTUALENV_PATH##*/}" --yes "${VIRTUALENV_OPTIONS[@]}" --file <(pyenv-exec conda list python --full-name --export) || STATUS="$?"
612+
else
613+
pyenv-exec conda create $QUIET $VERBOSE --name "${VIRTUALENV_PATH##*/}" --yes "${VIRTUALENV_OPTIONS[@]}" || STATUS="$?"
614+
fi
609615
else
610616
if [ -n "${USE_M_VENV}" ]; then
611617
pyenv-exec "${M_VENV_PYTHON_BIN:-python}" -m venv $QUIET $VERBOSE "${VIRTUALENV_OPTIONS[@]}" "${VIRTUALENV_PATH}" || STATUS="$?"

test/conda.bats

+4-4
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ unstub_pyenv() {
3232
run pyenv-virtualenv venv
3333

3434
assert_success
35-
assert_output <<OUT
36-
PYENV_VERSION=miniconda3-3.16.0 conda create --name venv --yes python
35+
assert_output_wildcards <<OUT
36+
PYENV_VERSION=miniconda3-3.16.0 conda create --name venv --yes --file /dev/fd/*
3737
rehashed
3838
OUT
3939

@@ -56,7 +56,7 @@ OUT
5656

5757
assert_success
5858
assert_output <<OUT
59-
PYENV_VERSION=miniconda3-3.16.0 conda create --name venv --yes python=3.5 python
59+
PYENV_VERSION=miniconda3-3.16.0 conda create --name venv --yes python=3.5
6060
rehashed
6161
OUT
6262

@@ -79,7 +79,7 @@ OUT
7979

8080
assert_success
8181
assert_output <<OUT
82-
PYENV_VERSION=miniconda3-3.16.0 conda create --name venv --yes python=3.5 python
82+
PYENV_VERSION=miniconda3-3.16.0 conda create --name venv --yes python=3.5
8383
rehashed
8484
OUT
8585

test/deactivate.bats

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env bats
1+
#!/usr/bin/env bats
22

33
load test_helper
44

test/test_helper.bash

+18
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,16 @@ assert_equal() {
8383
fi
8484
}
8585

86+
assert_equal_wildcards() {
87+
if [[ $1 != $2 ]]; then
88+
{ echo "expected:"
89+
echo "$2"
90+
echo "actual:"
91+
echo "$1"
92+
} | flunk
93+
fi
94+
}
95+
8696
assert_output() {
8797
local expected
8898
if [ $# -eq 0 ]; then expected="$(cat -)"
@@ -91,6 +101,14 @@ assert_output() {
91101
assert_equal "$expected" "$output"
92102
}
93103

104+
assert_output_wildcards() {
105+
local expected
106+
if [ $# -eq 0 ]; then expected="$(cat -)"
107+
else expected="$1"
108+
fi
109+
assert_equal_wildcards "$output" "$expected"
110+
}
111+
94112
assert_output_contains() {
95113
local expected="$1"
96114
echo "$output" | grep -F "$expected" >/dev/null || {

0 commit comments

Comments
 (0)