Skip to content

Commit 02cdf56

Browse files
committed
Add Debian Testing to the tests
1 parent 16ae9cb commit 02cdf56

File tree

4 files changed

+131
-0
lines changed

4 files changed

+131
-0
lines changed
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
#!/bin/sh
2+
3+
# SPDX-FileCopyrightText: 2021-2022 Gioele Barabucci
4+
# SPDX-License-Identifier: ISC
5+
6+
set -eu
7+
8+
export LC_ALL="C.UTF-8"
9+
10+
help () {
11+
cat <<-EOD
12+
Usage: lsb_release [options]
13+
14+
Options:
15+
-h, --help show this help message and exit
16+
-v, --version show LSB modules this system supports
17+
-i, --id show distributor ID
18+
-d, --description show description of this distribution
19+
-r, --release show release number of this distribution
20+
-c, --codename show code name of this distribution
21+
-a, --all show all of the above information
22+
-s, --short show requested information in short format
23+
EOD
24+
exit
25+
}
26+
27+
show_id=false
28+
show_desc=false
29+
show_release=false
30+
show_codename=false
31+
short_format=false
32+
33+
options=$(getopt --name lsb_release -o hvidrcas -l help,version,id,description,release,codename,all,short -- "$@") || exit 2
34+
eval set -- "$options"
35+
while [ $# -gt 0 ] ; do
36+
case "$1" in
37+
-h|--help) help ;;
38+
-v|--version) ;;
39+
-i|--id) show_id=true ;;
40+
-d|--description) show_desc=true ;;
41+
-r|--release) show_release=true ;;
42+
-c|--codename) show_codename=true ;;
43+
-a|--all) show_id=true ; show_desc=true ; show_release=true ; show_codename=true ;;
44+
-s|--short) short_format=true ;;
45+
*) break ;;
46+
esac
47+
shift
48+
done
49+
50+
display_line () {
51+
label="$1"
52+
value="$2"
53+
54+
if $short_format ; then
55+
printf "%s\n" "$value"
56+
else
57+
printf "%s:\t%s\n" "$label" "$value"
58+
fi
59+
}
60+
61+
# Load release info from standard identification data files
62+
[ -f /usr/lib/os-release ] && os_release=/usr/lib/os-release
63+
[ -f /etc/os-release ] && os_release=/etc/os-release
64+
[ "${LSB_OS_RELEASE-x}" != "x" ] && [ -f "$LSB_OS_RELEASE" ] && os_release="$LSB_OS_RELEASE"
65+
[ "${os_release-x}" != "x" ] && . "$os_release"
66+
67+
# Mimic the output of Debian's Python-based lsb_release
68+
# Capitalize ID
69+
: "${ID=}"
70+
ID="$(printf "%s" "$ID" | cut -c1 | tr '[:lower:]' '[:upper:]')$(printf "%s" "$ID" | cut -c2-)"
71+
# Use NAME if set and different from ID only in capitalization.
72+
if [ "${NAME-x}" != "x" ] ; then
73+
lower_case_id=$(printf "%s" "$ID" | tr '[:upper:]' '[:lower:]')
74+
lower_case_name=$(printf "%s" "$NAME" | tr '[:upper:]' '[:lower:]')
75+
if [ "${lower_case_id}" = "${lower_case_name}" ] ; then
76+
ID="$NAME"
77+
fi
78+
fi
79+
80+
# Generate minimal standard-conform output (if stdout is a TTY).
81+
[ -t 1 ] && echo "No LSB modules are available." >& 2
82+
83+
if $show_id ; then
84+
display_line "Distributor ID" "${ID:-n/a}"
85+
fi
86+
87+
if $show_desc ; then
88+
display_line "Description" "${PRETTY_NAME:-n/a}"
89+
fi
90+
91+
if $show_release ; then
92+
display_line "Release" "${VERSION_ID:-n/a}"
93+
fi
94+
95+
if $show_codename ; then
96+
display_line "Codename" "${VERSION_CODENAME:-n/a}"
97+
fi
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
bookworm/sid
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
PRETTY_NAME="Debian GNU/Linux bookworm/sid"
2+
NAME="Debian GNU/Linux"
3+
VERSION_CODENAME=bookworm
4+
ID=debian
5+
HOME_URL="https://www.debian.org/"
6+
SUPPORT_URL="https://www.debian.org/support"
7+
BUG_REPORT_URL="https://bugs.debian.org/"

tests/test_distro.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,18 @@ def test_debian10_os_release(self) -> None:
233233
}
234234
self._test_outcome(desired_outcome)
235235

236+
def test_debiantesting_os_release(self) -> None:
237+
desired_outcome = {
238+
"id": "debian",
239+
"name": "Debian GNU/Linux",
240+
"pretty_name": "Debian GNU/Linux bookworm/sid",
241+
"version": "bookworm/sid",
242+
"pretty_version": "bookworm/sid (bookworm)",
243+
"best_version": "bookworm/sid",
244+
"codename": "bookworm",
245+
}
246+
self._test_outcome(desired_outcome)
247+
236248
def test_fedora19_os_release(self) -> None:
237249
desired_outcome = {
238250
"id": "fedora",
@@ -1255,6 +1267,20 @@ def test_debian10_release(self) -> None:
12551267
self._test_outcome(desired_outcome)
12561268
self._test_non_existing_release_file()
12571269

1270+
def test_debiantesting_release(self) -> None:
1271+
desired_outcome = {
1272+
"id": "debian",
1273+
"name": "Debian GNU/Linux",
1274+
"pretty_name": "Debian GNU/Linux bookworm/sid",
1275+
"version": "bookworm/sid",
1276+
"pretty_version": "bookworm/sid (bookworm)",
1277+
"best_version": "bookworm/sid",
1278+
"codename": "bookworm",
1279+
"major_version": "",
1280+
}
1281+
self._test_outcome(desired_outcome)
1282+
self._test_non_existing_release_file()
1283+
12581284
def test_exherbo_release(self) -> None:
12591285
desired_outcome = {
12601286
"id": "exherbo",

0 commit comments

Comments
 (0)