OILS / test / spec-version.sh View on Github | oilshell.org

124 lines, 88 significant
1#!/usr/bin/env bash
2#
3# Called from the end of html-summary in test/spec-runner.sh.
4#
5# Usage:
6# test/spec-version.sh <function name>
7
8set -o nounset
9set -o pipefail
10set -o errexit
11
12REPO_ROOT=$(cd "$(dirname $0)/.."; pwd)
13
14source devtools/run-task.sh
15source test/common.sh # date-and-git-info
16source test/spec-common.sh # OSH_LIST
17
18maybe-show() {
19 local path=$1
20 if test -f $path; then
21 echo "--- $path ---"
22 cat $path
23 echo
24 fi
25}
26
27ysh-version-text() {
28 date-and-git-info
29
30 for bin in $YSH_LIST; do
31 echo ---
32 echo "\$ $bin --version"
33 $bin --version
34 echo
35 done
36
37 maybe-show /etc/alpine-release
38 maybe-show /etc/debian_version
39 maybe-show /etc/lsb-release
40}
41
42# TODO: Refactor this so you get the shells
43# test/sh_spec.py --shells
44# And then do 'bash dash mksh zsh ash' IF they exist?
45# That should be fine because we do check-survey-shells BEFORE running
46
47osh-version-text() {
48
49 local -a osh_list
50 if test $# -eq 0; then
51 osh_list=( $OSH_LIST ) # word splitting
52 else
53 osh_list=( "$@" ) # explicit arguments
54 fi
55
56 date-and-git-info
57
58 for bin in "${osh_list[@]}"; do
59 echo ---
60 echo "\$ $bin --version"
61 $bin --version
62 echo
63 done
64
65 # $BASH and $ZSH should exist
66
67 echo ---
68 bash --version | head -n 1
69 ls -l $(type -p bash)
70 echo
71
72 echo ---
73 zsh --version | head -n 1
74 ls -l $(type -p zsh)
75 echo
76
77 # No -v or -V or --version. TODO: Only use hermetic version on release.
78
79 echo ---
80 local my_dash
81 my_dash=$(type -p dash)
82 if test -f $my_dash; then
83 ls -l $my_dash
84 else
85 dpkg -s dash | egrep '^Package|Version'
86 fi
87 echo
88
89 echo ---
90 local my_mksh
91 my_mksh=$(type -p mksh)
92 if test -f $my_mksh; then
93 ls -l $my_mksh
94 else
95 dpkg -s mksh | egrep '^Package|Version'
96 fi
97 echo
98
99 echo ---
100 local my_busybox
101 my_busybox=$(type -p busybox)
102 if test -f $my_busybox; then
103 { $my_busybox || true; } | head -n 1
104 ls -l $my_busybox
105 else
106 # Need || true because of pipefail
107 { busybox || true; } | head -n 1
108 fi
109 echo
110
111 maybe-show /etc/debian_version
112 maybe-show /etc/lsb-release
113 maybe-show /etc/alpine-release
114}
115
116osh-minimal-version-text() {
117 osh-version-text
118}
119
120interactive-version-text() {
121 osh-version-text
122}
123
124run-task "$@"