Skip to content

Commit

Permalink
Merge pull request #202 from mbland/platform-freebsd
Browse files Browse the repository at this point in the history
lib/platform: Add freebsd _GO_PLATFORM_ID
  • Loading branch information
mbland authored Sep 2, 2017
2 parents 7a9619d + dd44e0e commit fb58534
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/platform
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
# environment variables if `/etc/os-release` if present, or just
# `_GO_PLATFORM_ID` otherwise, which is set to:
#
# - 'macos' if the Bash variable `OSTYPE` matches 'darwin'
# - 'macos' if the Bash variable `$OSTYPE` matches 'darwin'
# - 'freebsd' if `$OSTYPE` matches 'freebsd'
# - 'msys-git' if `git --version` matches 'windows'
# - `$OSTYPE` in all other cases
#
Expand Down Expand Up @@ -35,9 +36,15 @@ [email protected]_os_release() {
}

[email protected]_ostype() {
# We elide `$OSTYPE` values into more inclusive values such as 'macos' and
# 'freebsd' since we expect most scripts to treat different versions of a
# platform largely the same way.
case "$OSTYPE" in
darwin*)
_GO_PLATFORM_ID='macos'
_GO_PLATFORM_ID='macos'
;;
freebsd*)
_GO_PLATFORM_ID='freebsd'
;;
msys)
_GO_PLATFORM_ID='msys'
Expand Down
5 changes: 5 additions & 0 deletions tests/platform.bats
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ teardown() {
assert_success '_GO_PLATFORM_ID="macos"'
}

@test "$SUITE: set _GO_PLATFORM_ID to freebsd from OSTYPE" {
OSTYPE='freebsd11.0' run "$TEST_GO_SCRIPT"
assert_success '_GO_PLATFORM_ID="freebsd"'
}

@test "$SUITE: set _GO_PLATFORM_ID to msys from OSTYPE" {
stub_program_in_path 'git' 'printf "%s\n" "git version 2.13.0"'
OSTYPE='msys' run "$TEST_GO_SCRIPT"
Expand Down

0 comments on commit fb58534

Please sign in to comment.