From 366e69bf8202258bb052fbd15177fd5d9d0cd2b8 Mon Sep 17 00:00:00 2001 From: Ilan Cosman Date: Sun, 10 Apr 2022 13:34:06 -0700 Subject: [PATCH] Improve detect_os tests --- Makefile | 6 +++--- tests/_tide_detect_os.test.fish | 8 ------- tests/detect_os/_tide_detect_os.test.fish | 26 +++++++++++++++++++++++ tests/detect_os/endeavouros-etc-release | 11 ++++++++++ tests/detect_os/opensuse-etc-release | 12 +++++++++++ 5 files changed, 52 insertions(+), 11 deletions(-) delete mode 100644 tests/_tide_detect_os.test.fish create mode 100644 tests/detect_os/_tide_detect_os.test.fish create mode 100644 tests/detect_os/endeavouros-etc-release create mode 100644 tests/detect_os/opensuse-etc-release diff --git a/Makefile b/Makefile index 0c047fe..fff8ba2 100644 --- a/Makefile +++ b/Makefile @@ -5,11 +5,11 @@ all: fmt lint install test .PHONY: fmt fmt: - @fish_indent --write **/*.fish + @fish_indent --write **.fish .PHONY: lint lint: - @for file in **/*.fish; fish --no-execute $$file; end + @for file in **.fish; fish --no-execute $$file; end .PHONY: install install: @@ -24,4 +24,4 @@ test: install littlecheck.py @type -q mock || fisher install IlanCosman/clownfish @fish tests/test_setup.fish @_tide_remove_unusable_items - @_tide_cache_variables; python3 littlecheck.py --progress tests/*.test.fish + @_tide_cache_variables; python3 littlecheck.py --progress tests/**.test.fish diff --git a/tests/_tide_detect_os.test.fish b/tests/_tide_detect_os.test.fish deleted file mode 100644 index cf37e10..0000000 --- a/tests/_tide_detect_os.test.fish +++ /dev/null @@ -1,8 +0,0 @@ -# RUN: %fish %s -# Only run this test on macOS: -# REQUIRES: test $(uname) = Darwin - -_tide_detect_os -# CHECK:  -# CHECK: D6D6D6 -# CHECK: 333333 diff --git a/tests/detect_os/_tide_detect_os.test.fish b/tests/detect_os/_tide_detect_os.test.fish new file mode 100644 index 0000000..5b8a226 --- /dev/null +++ b/tests/detect_os/_tide_detect_os.test.fish @@ -0,0 +1,26 @@ +# RUN: %fish %s + +mock uname \* "echo Darwin" + +_tide_detect_os +# CHECK:  +# CHECK: D6D6D6 +# CHECK: 333333 + +function _detect_os_linux_cases -a file + set -l dir (status dirname) + _tide_detect_os_linux_cases $dir/$file ID || + _tide_detect_os_linux_cases $dir/$file ID_LIKE || + _tide_detect_os_linux_cases $dir/$file DISTRIB_ID +end + +_detect_os_linux_cases endeavouros-etc-release +# CHECK:  +# CHECK: 1793D1 +# CHECK: 4D4D4D + +# This tests spaces, e.g "opensuse suse" +_detect_os_linux_cases opensuse-etc-release +# CHECK:  +# CHECK: 73BA25 +# CHECK: 173f4f diff --git a/tests/detect_os/endeavouros-etc-release b/tests/detect_os/endeavouros-etc-release new file mode 100644 index 0000000..2dc3eb4 --- /dev/null +++ b/tests/detect_os/endeavouros-etc-release @@ -0,0 +1,11 @@ +NAME=EndeavourOS +PRETTY_NAME=EndeavourOS +ID=endeavouros +ID_LIKE=arch +BUILD_ID=2021.12.17 +ANSI_COLOR="38;2;23;147;209" +HOME_URL='https://endeavouros.com' +DOCUMENTATION_URL='https://forum.endeavouros.com/c/Arch-based-related-questions/bug-reports' +SUPPORT_URL='https://forum.endeavouros.com' +BUG_REPORT_URL='https://forum.endeavouros.com/c/arch-based-related-questions/bug-reports' +LOGO=endeavouros diff --git a/tests/detect_os/opensuse-etc-release b/tests/detect_os/opensuse-etc-release new file mode 100644 index 0000000..84cd4e4 --- /dev/null +++ b/tests/detect_os/opensuse-etc-release @@ -0,0 +1,12 @@ +NAME="openSUSE Tumbleweed" +# VERSION="20220408" +ID="opensuse-tumbleweed" +ID_LIKE="opensuse suse" +VERSION_ID="20220408" +PRETTY_NAME="openSUSE Tumbleweed" +ANSI_COLOR="0;32" +CPE_NAME="cpe:/o:opensuse:tumbleweed:20220408" +BUG_REPORT_URL="https://bugs.opensuse.org" +HOME_URL="https://www.opensuse.org/" +DOCUMENTATION_URL="https://en.opensuse.org/Portal:Tumbleweed" +LOGO="distributor-logo-Tumbleweed"