Skip to content

Commit

Permalink
fix: Update $mktemp to support macOS
Browse files Browse the repository at this point in the history
This patch updates the instances of $mktemp in the govc/test/*.bats
files to support the macOS variant.
  • Loading branch information
akutz committed Dec 12, 2022
1 parent 05b0b08 commit 22c4814
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions govc/test/import.bats
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ load test_helper
assert_success

# ensure vcsim doesn't panic without capacityAllocationUnits
dir=$($mktemp --tmpdir -d govc-test-XXXXX)
dir=$($mktemp --tmpdir -d govc-test-XXXXX 2>/dev/null || $mktemp -d -t govc-test-XXXXX)
sed -e s/capacityAllocationUnits/invalid/ "$GOVC_IMAGES/$TTYLINUX_NAME.ovf" > "$dir/$TTYLINUX_NAME.ovf"
touch "$dir/$TTYLINUX_NAME-disk1.vmdk" # .vmdk contents don't matter to vcsim
run govc import.ovf "$dir/$TTYLINUX_NAME.ovf"
Expand All @@ -98,7 +98,7 @@ load test_helper
vcsim_env

name=$(new_id)
file=$($mktemp --tmpdir govc-test-XXXXX)
file=$($mktemp --tmpdir govc-test-XXXXX 2>/dev/null || $mktemp -t govc-test-XXXXX)
echo "{ \"Name\": \"${name}\"}" > ${file}

run govc import.ovf -options="${file}" $GOVC_IMAGES/${TTYLINUX_NAME}.ovf
Expand All @@ -113,7 +113,7 @@ load test_helper
@test "import.ovf with import.spec result" {
vcsim_env

file=$($mktemp --tmpdir govc-test-XXXXX)
file=$($mktemp --tmpdir govc-test-XXXXX 2>/dev/null || $mktemp -t govc-test-XXXXX)
name=$(new_id)

govc import.spec $GOVC_IMAGES/${TTYLINUX_NAME}.ovf > ${file}
Expand Down
8 changes: 4 additions & 4 deletions govc/test/session.bats
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ load test_helper
@test "session.rm" {
vcsim_env

dir=$($mktemp --tmpdir -d govc-test-XXXXX)
dir=$($mktemp --tmpdir -d govc-test-XXXXX 2>/dev/null || $mktemp -d -t govc-test-XXXXX)
export GOVMOMI_HOME="$dir"
export GOVC_PERSIST_SESSION=true

Expand All @@ -48,7 +48,7 @@ load test_helper
@test "session.persist" {
vcsim_env

dir=$($mktemp --tmpdir -d govc-test-XXXXX)
dir=$($mktemp --tmpdir -d govc-test-XXXXX 2>/dev/null || $mktemp -d -t govc-test-XXXXX)
export GOVMOMI_HOME="$dir"
export GOVC_PERSIST_SESSION=true

Expand Down Expand Up @@ -102,7 +102,7 @@ load test_helper
assert_success

user=$(govc env GOVC_USERNAME)
dir=$($mktemp --tmpdir -d govc-test-XXXXX)
dir=$($mktemp --tmpdir -d govc-test-XXXXX 2>/dev/null || $mktemp -d -t govc-test-XXXXX)
export GOVMOMI_HOME="$dir"
export GOVC_PERSIST_SESSION=true

Expand Down Expand Up @@ -137,7 +137,7 @@ load test_helper
vcsim_env

user=$(govc env GOVC_USERNAME)
dir=$($mktemp --tmpdir -d govc-test-XXXXX)
dir=$($mktemp --tmpdir -d govc-test-XXXXX 2>/dev/null || $mktemp -d -t govc-test-XXXXX)
export GOVMOMI_HOME="$dir"
export GOVC_PERSIST_SESSION=true

Expand Down
2 changes: 1 addition & 1 deletion govc/test/vcsim.bats
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ EOF

vcsim_stop

dir=$($mktemp --tmpdir -d govc-test-XXXXX)
dir=$($mktemp --tmpdir -d govc-test-XXXXX 2>/dev/null || $mktemp -d -t govc-test-XXXXX)
echo nobody > "$dir/username"
echo nothing > "$dir/password"

Expand Down

0 comments on commit 22c4814

Please sign in to comment.