File tree Expand file tree Collapse file tree 2 files changed +61
-0
lines changed Expand file tree Collapse file tree 2 files changed +61
-0
lines changed Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+ #
3+ # Prints go-script-bash, Bash, and operating system version information
4+ #
5+ # Useful for diagnosing problems and filing bug reports.
6+ #
7+ # More information may be gleaned from `uname`, as well as `sw_vers` on macOS,
8+ # but this includes the most often relevant information.
9+
10+ . " $_GO_USE_MODULES " ' format' ' platform'
11+
12+ _@go.gocore () {
13+ local varnames=(' _GO_CORE_VERSION'
14+ ' BASH_VERSION'
15+ ' OSTYPE'
16+ ' _GO_PLATFORM_ID'
17+ ' _GO_PLATFORM_VERSION_ID' )
18+ local values=()
19+ local varname
20+ local result=()
21+
22+ for varname in " ${varnames[@]} " ; do
23+ values+=(" ${! varname} " )
24+ done
25+
26+ @go.pad_items ' varnames' " ${varnames[@]/%/: } "
27+ @go.zip_items ' varnames' ' values' ' ' result
28+ printf ' %s\n' " ${result[@]} "
29+ }
30+
31+ _@go.gocore " $@ "
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bats
2+
3+ load environment
4+
5+ setup () {
6+ test_filter
7+ @go.create_test_go_script ' @go "$@"'
8+ export __GO_ETC_OS_RELEASE=" $BATS_TEST_ROOTDIR /os-release"
9+ }
10+
11+ teardown () {
12+ @go.remove_test_go_rootdir
13+ }
14+
15+ @test " $SUITE : emit version information about framework, Bash, and OS" {
16+ # Use simulated /etc/os-release to prevent computation via uname or sw_vers.
17+ mkdir -p " $BATS_TEST_ROOTDIR "
18+ printf ' %s\n' \
19+ ' ID=foobar' \
20+ ' VERSION_ID=666' > " $__GO_ETC_OS_RELEASE "
21+
22+ run " $TEST_GO_SCRIPT " ' goinfo'
23+ assert_success
24+ assert_lines_equal \
25+ " _GO_CORE_VERSION: $_GO_CORE_VERSION " \
26+ " BASH_VERSION: $BASH_VERSION " \
27+ " OSTYPE: $OSTYPE " \
28+ ' _GO_PLATFORM_ID: foobar' \
29+ ' _GO_PLATFORM_VERSION_ID: 666'
30+ }
You can’t perform that action at this time.
0 commit comments