Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 19 additions & 73 deletions test/system/220-environment-variables.bats
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# shellcheck shell=bats
#
# Copyright © 2023 – 2024 Red Hat, Inc.
# Copyright © 2023 – 2025 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -21,22 +21,36 @@ load 'libs/bats-support/load'
load 'libs/bats-assert/load'
load 'libs/helpers'

setup() {
setup_file() {
bats_require_minimum_version 1.10.0
_setup_environment
cleanup_all
pushd "$HOME" || return 1

if echo "$TOOLBX_TEST_SYSTEM_TAGS" | grep "arch" >/dev/null 2>/dev/null; then
create_distro_container arch latest arch-toolbox-latest
fi

if echo "$TOOLBX_TEST_SYSTEM_TAGS" | grep "fedora" >/dev/null 2>/dev/null; then
create_default_container
create_distro_container fedora 34 fedora-toolbox-34
create_distro_container rhel 8.10 rhel-toolbox-8.10
fi

if echo "$TOOLBX_TEST_SYSTEM_TAGS" | grep "ubuntu" >/dev/null 2>/dev/null; then
create_distro_container ubuntu 16.04 ubuntu-toolbox-16.04
create_distro_container ubuntu 18.04 ubuntu-toolbox-18.04
create_distro_container ubuntu 20.04 ubuntu-toolbox-20.04
fi
}

teardown() {
teardown_file() {
popd || return 1
cleanup_all
}

# bats test_tags=arch-fedora
@test "environment variables: HISTFILESIZE inside the default container" {
create_default_container

if [ "$HISTFILESIZE" = "" ]; then
# shellcheck disable=SC2030
HISTFILESIZE=1001
Expand All @@ -59,8 +73,6 @@ teardown() {

# bats test_tags=arch-fedora
@test "environment variables: HISTFILESIZE inside Arch Linux" {
create_distro_container arch latest arch-toolbox-latest

# shellcheck disable=SC2031
if [ "$HISTFILESIZE" = "" ]; then
# shellcheck disable=SC2030
Expand All @@ -84,8 +96,6 @@ teardown() {

# bats test_tags=arch-fedora
@test "environment variables: HISTFILESIZE inside Fedora 34" {
create_distro_container fedora 34 fedora-toolbox-34

# shellcheck disable=SC2031
if [ "$HISTFILESIZE" = "" ]; then
# shellcheck disable=SC2030
Expand All @@ -109,8 +119,6 @@ teardown() {

# bats test_tags=arch-fedora
@test "environment variables: HISTFILESIZE inside RHEL 8.10" {
create_distro_container rhel 8.10 rhel-toolbox-8.10

# shellcheck disable=SC2031
if [ "$HISTFILESIZE" = "" ]; then
# shellcheck disable=SC2030
Expand All @@ -134,8 +142,6 @@ teardown() {

# bats test_tags=ubuntu
@test "environment variables: HISTFILESIZE inside Ubuntu 16.04" {
create_distro_container ubuntu 16.04 ubuntu-toolbox-16.04

# shellcheck disable=SC2031
if [ "$HISTFILESIZE" = "" ]; then
# shellcheck disable=SC2030
Expand All @@ -160,8 +166,6 @@ teardown() {

# bats test_tags=ubuntu
@test "environment variables: HISTFILESIZE inside Ubuntu 18.04" {
create_distro_container ubuntu 18.04 ubuntu-toolbox-18.04

# shellcheck disable=SC2031
if [ "$HISTFILESIZE" = "" ]; then
# shellcheck disable=SC2030
Expand All @@ -186,8 +190,6 @@ teardown() {

# bats test_tags=ubuntu
@test "environment variables: HISTFILESIZE inside Ubuntu 20.04" {
create_distro_container ubuntu 20.04 ubuntu-toolbox-20.04

# shellcheck disable=SC2031
if [ "$HISTFILESIZE" = "" ]; then
HISTFILESIZE=1001
Expand All @@ -213,8 +215,6 @@ teardown() {
@test "environment variables: HISTSIZE inside the default container" {
skip "https://pagure.io/setup/pull-request/48"

create_default_container

if [ "$HISTSIZE" = "" ]; then
# shellcheck disable=SC2030
HISTSIZE=1001
Expand All @@ -237,8 +237,6 @@ teardown() {

# bats test_tags=arch-fedora
@test "environment variables: HISTSIZE inside Arch Linux" {
create_distro_container arch latest arch-toolbox-latest

# shellcheck disable=SC2031
if [ "$HISTSIZE" = "" ]; then
# shellcheck disable=SC2030
Expand All @@ -264,8 +262,6 @@ teardown() {
@test "environment variables: HISTSIZE inside Fedora 34" {
skip "https://pagure.io/setup/pull-request/48"

create_distro_container fedora 34 fedora-toolbox-34

# shellcheck disable=SC2031
if [ "$HISTSIZE" = "" ]; then
# shellcheck disable=SC2030
Expand All @@ -291,8 +287,6 @@ teardown() {
@test "environment variables: HISTSIZE inside RHEL 8.10" {
skip "https://pagure.io/setup/pull-request/48"

create_distro_container rhel 8.10 rhel-toolbox-8.10

# shellcheck disable=SC2031
if [ "$HISTSIZE" = "" ]; then
# shellcheck disable=SC2030
Expand All @@ -316,8 +310,6 @@ teardown() {

# bats test_tags=ubuntu
@test "environment variables: HISTSIZE inside Ubuntu 16.04" {
create_distro_container ubuntu 16.04 ubuntu-toolbox-16.04

# shellcheck disable=SC2031
if [ "$HISTSIZE" = "" ]; then
# shellcheck disable=SC2030
Expand All @@ -341,8 +333,6 @@ teardown() {

# bats test_tags=ubuntu
@test "environment variables: HISTSIZE inside Ubuntu 18.04" {
create_distro_container ubuntu 18.04 ubuntu-toolbox-18.04

# shellcheck disable=SC2031
if [ "$HISTSIZE" = "" ]; then
# shellcheck disable=SC2030
Expand All @@ -366,8 +356,6 @@ teardown() {

# bats test_tags=ubuntu
@test "environment variables: HISTSIZE inside Ubuntu 20.04" {
create_distro_container ubuntu 20.04 ubuntu-toolbox-20.04

# shellcheck disable=SC2031
if [ "$HISTSIZE" = "" ]; then
HISTSIZE=1001
Expand All @@ -390,8 +378,6 @@ teardown() {

# bats test_tags=arch-fedora
@test "environment variables: HOSTNAME inside the default container" {
create_default_container

# shellcheck disable=SC2016
run --keep-empty-lines --separate-stderr "$TOOLBX" run bash -c 'echo "$HOSTNAME"'

Expand All @@ -403,8 +389,6 @@ teardown() {

# bats test_tags=arch-fedora
@test "environment variables: HOSTNAME inside Arch Linux" {
create_distro_container arch latest arch-toolbox-latest

# shellcheck disable=SC2016
run --keep-empty-lines --separate-stderr "$TOOLBX" run --distro arch bash -c 'echo "$HOSTNAME"'

Expand All @@ -416,8 +400,6 @@ teardown() {

# bats test_tags=arch-fedora
@test "environment variables: HOSTNAME inside Fedora 34" {
create_distro_container fedora 34 fedora-toolbox-34

# shellcheck disable=SC2016
run --keep-empty-lines --separate-stderr "$TOOLBX" run --distro fedora --release 34 bash -c 'echo "$HOSTNAME"'

Expand All @@ -429,8 +411,6 @@ teardown() {

# bats test_tags=arch-fedora
@test "environment variables: HOSTNAME inside RHEL 8.10" {
create_distro_container rhel 8.10 rhel-toolbox-8.10

# shellcheck disable=SC2016
run --keep-empty-lines --separate-stderr "$TOOLBX" run --distro rhel --release 8.10 bash -c 'echo "$HOSTNAME"'

Expand All @@ -442,8 +422,6 @@ teardown() {

# bats test_tags=ubuntu
@test "environment variables: HOSTNAME inside Ubuntu 16.04" {
create_distro_container ubuntu 16.04 ubuntu-toolbox-16.04

# shellcheck disable=SC2016
run --keep-empty-lines --separate-stderr "$TOOLBX" run --distro ubuntu --release 16.04 bash -c 'echo "$HOSTNAME"'

Expand All @@ -455,8 +433,6 @@ teardown() {

# bats test_tags=ubuntu
@test "environment variables: HOSTNAME inside Ubuntu 18.04" {
create_distro_container ubuntu 18.04 ubuntu-toolbox-18.04

# shellcheck disable=SC2016
run --keep-empty-lines --separate-stderr "$TOOLBX" run --distro ubuntu --release 18.04 bash -c 'echo "$HOSTNAME"'

Expand All @@ -468,8 +444,6 @@ teardown() {

# bats test_tags=ubuntu
@test "environment variables: HOSTNAME inside Ubuntu 20.04" {
create_distro_container ubuntu 20.04 ubuntu-toolbox-20.04

# shellcheck disable=SC2016
run --keep-empty-lines --separate-stderr "$TOOLBX" run --distro ubuntu --release 20.04 bash -c 'echo "$HOSTNAME"'

Expand All @@ -481,8 +455,6 @@ teardown() {

# bats test_tags=arch-fedora
@test "environment variables: KONSOLE_VERSION inside the default container" {
create_default_container

if [ "$KONSOLE_VERSION" = "" ]; then
# shellcheck disable=SC2030
export KONSOLE_VERSION=230804
Expand All @@ -501,8 +473,6 @@ teardown() {

# bats test_tags=arch-fedora
@test "environment variables: KONSOLE_VERSION inside Arch Linux" {
create_distro_container arch latest arch-toolbox-latest

# shellcheck disable=SC2031
if [ "$KONSOLE_VERSION" = "" ]; then
# shellcheck disable=SC2030
Expand All @@ -522,8 +492,6 @@ teardown() {

# bats test_tags=arch-fedora
@test "environment variables: KONSOLE_VERSION inside Fedora 34" {
create_distro_container fedora 34 fedora-toolbox-34

# shellcheck disable=SC2031
if [ "$KONSOLE_VERSION" = "" ]; then
# shellcheck disable=SC2030
Expand All @@ -543,8 +511,6 @@ teardown() {

# bats test_tags=arch-fedora
@test "environment variables: KONSOLE_VERSION inside RHEL 8.10" {
create_distro_container rhel 8.10 rhel-toolbox-8.10

# shellcheck disable=SC2031
if [ "$KONSOLE_VERSION" = "" ]; then
# shellcheck disable=SC2030
Expand All @@ -564,8 +530,6 @@ teardown() {

# bats test_tags=ubuntu
@test "environment variables: KONSOLE_VERSION inside Ubuntu 16.04" {
create_distro_container ubuntu 16.04 ubuntu-toolbox-16.04

# shellcheck disable=SC2031
if [ "$KONSOLE_VERSION" = "" ]; then
# shellcheck disable=SC2030
Expand All @@ -585,8 +549,6 @@ teardown() {

# bats test_tags=ubuntu
@test "environment variables: KONSOLE_VERSION inside Ubuntu 18.04" {
create_distro_container ubuntu 18.04 ubuntu-toolbox-18.04

# shellcheck disable=SC2031
if [ "$KONSOLE_VERSION" = "" ]; then
# shellcheck disable=SC2030
Expand All @@ -606,8 +568,6 @@ teardown() {

# bats test_tags=ubuntu
@test "environment variables: KONSOLE_VERSION inside Ubuntu 20.04" {
create_distro_container ubuntu 20.04 ubuntu-toolbox-20.04

# shellcheck disable=SC2031
if [ "$KONSOLE_VERSION" = "" ]; then
export KONSOLE_VERSION=230804
Expand All @@ -626,8 +586,6 @@ teardown() {

# bats test_tags=arch-fedora
@test "environment variables: XTERM_VERSION inside the default container" {
create_default_container

if [ "$XTERM_VERSION" = "" ]; then
# shellcheck disable=SC2030
export XTERM_VERSION="XTerm(385)"
Expand All @@ -646,8 +604,6 @@ teardown() {

# bats test_tags=arch-fedora
@test "environment variables: XTERM_VERSION inside Arch Linux" {
create_distro_container arch latest arch-toolbox-latest

# shellcheck disable=SC2031
if [ "$XTERM_VERSION" = "" ]; then
# shellcheck disable=SC2030
Expand All @@ -667,8 +623,6 @@ teardown() {

# bats test_tags=arch-fedora
@test "environment variables: XTERM_VERSION inside Fedora 34" {
create_distro_container fedora 34 fedora-toolbox-34

# shellcheck disable=SC2031
if [ "$XTERM_VERSION" = "" ]; then
# shellcheck disable=SC2030
Expand All @@ -688,8 +642,6 @@ teardown() {

# bats test_tags=arch-fedora
@test "environment variables: XTERM_VERSION inside RHEL 8.10" {
create_distro_container rhel 8.10 rhel-toolbox-8.10

# shellcheck disable=SC2031
if [ "$XTERM_VERSION" = "" ]; then
# shellcheck disable=SC2030
Expand All @@ -709,8 +661,6 @@ teardown() {

# bats test_tags=ubuntu
@test "environment variables: XTERM_VERSION inside Ubuntu 16.04" {
create_distro_container ubuntu 16.04 ubuntu-toolbox-16.04

# shellcheck disable=SC2031
if [ "$XTERM_VERSION" = "" ]; then
# shellcheck disable=SC2030
Expand All @@ -730,8 +680,6 @@ teardown() {

# bats test_tags=ubuntu
@test "environment variables: XTERM_VERSION inside Ubuntu 18.04" {
create_distro_container ubuntu 18.04 ubuntu-toolbox-18.04

# shellcheck disable=SC2031
if [ "$XTERM_VERSION" = "" ]; then
# shellcheck disable=SC2030
Expand All @@ -751,8 +699,6 @@ teardown() {

# bats test_tags=ubuntu
@test "environment variables: XTERM_VERSION inside Ubuntu 20.04" {
create_distro_container ubuntu 20.04 ubuntu-toolbox-20.04

# shellcheck disable=SC2031
if [ "$XTERM_VERSION" = "" ]; then
export XTERM_VERSION="XTerm(385)"
Expand Down
Loading