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

129 lines, 92 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 echo ---
78 yash --version | head -n 1
79 ls -l $(type -p yash)
80 echo
81
82 # No -v or -V or --version. TODO: Only use hermetic version on release.
83
84 echo ---
85 local my_dash
86 my_dash=$(type -p dash)
87 if test -f $my_dash; then
88 ls -l $my_dash
89 else
90 dpkg -s dash | egrep '^Package|Version'
91 fi
92 echo
93
94 echo ---
95 local my_mksh
96 my_mksh=$(type -p mksh)
97 if test -f $my_mksh; then
98 ls -l $my_mksh
99 else
100 dpkg -s mksh | egrep '^Package|Version'
101 fi
102 echo
103
104 echo ---
105 local my_busybox
106 my_busybox=$(type -p busybox)
107 if test -f $my_busybox; then
108 { $my_busybox || true; } | head -n 1
109 ls -l $my_busybox
110 else
111 # Need || true because of pipefail
112 { busybox || true; } | head -n 1
113 fi
114 echo
115
116 maybe-show /etc/debian_version
117 maybe-show /etc/lsb-release
118 maybe-show /etc/alpine-release
119}
120
121osh-minimal-version-text() {
122 osh-version-text
123}
124
125interactive-version-text() {
126 osh-version-text
127}
128
129run-task "$@"