1
0
mirror of https://github.com/TheLocehiliosan/yadm synced 2024-10-27 20:34:27 +00:00
TheLocehiliosan_yadm/test/006_unit_set_operating_system.bats
Tim Byrne eabf9091fb
Support WSL detection (#61)
`uname -s` was already being executed every run for *cygwin* detection.
I've consolidated all of the OS detection into a single function. This
also fixed the problem of running `uname -s` twice for the `alt`
command.
2017-04-09 08:47:18 -05:00

77 lines
1.5 KiB
Bash

load common
load_fixtures
@test "Default OS" {
echo "
By default, the value of OPERATING_SYSTEM should be reported by uname -s
"
# shellcheck source=/dev/null
YADM_TEST=1 source "$T_YADM"
status=0
output=$( set_operating_system; echo "$OPERATING_SYSTEM" ) || {
status=$?
true
}
expected=$(uname -s 2>/dev/null)
echo "output=$output"
echo "expect=$expected"
[ "$status" == 0 ]
[ "$output" = "$expected" ]
}
@test "Detect no WSL" {
echo "
When /proc/version does not contain Microsoft, report uname -s
"
echo "proc version exists" > "$BATS_TMPDIR/proc_version"
# shellcheck source=/dev/null
YADM_TEST=1 source "$T_YADM"
# shellcheck disable=SC2034
PROC_VERSION="$BATS_TMPDIR/proc_version"
status=0
output=$( set_operating_system; echo "$OPERATING_SYSTEM" ) || {
status=$?
true
}
expected=$(uname -s 2>/dev/null)
echo "output=$output"
echo "expect=$expected"
[ "$status" == 0 ]
[ "$output" = "$expected" ]
}
@test "Detect WSL" {
echo "
When /proc/version contains Microsoft, report WSL
"
echo "proc version contains Microsoft in it" > "$BATS_TMPDIR/proc_version"
# shellcheck source=/dev/null
YADM_TEST=1 source "$T_YADM"
# shellcheck disable=SC2034
PROC_VERSION="$BATS_TMPDIR/proc_version"
status=0
output=$( set_operating_system; echo "$OPERATING_SYSTEM" ) || {
status=$?
true
}
expected="WSL"
echo "output=$output"
echo "expect=$expected"
[ "$status" == 0 ]
[ "$output" = "$expected" ]
}