From d1bf69f02a11d0613045bdcb491290501c937592 Mon Sep 17 00:00:00 2001 From: "(Holloway) Chew, Kean Ho" Date: Thu, 26 Dec 2024 11:52:29 +0800 Subject: [PATCH] Shell: added Is_Command_* functions suite Since the Is_Command_* functions suite was accidentally ported, it's better to commit it in. Hence, let's do this. This patch adds Is_Command_* functions suite into Shell/ directory. Co-authored-by: Shuralyov, Jean Co-authored-by: Galyna, Cory Co-authored-by: (Holloway) Chew, Kean Ho Signed-off-by: (Holloway) Chew, Kean Ho --- .../HestiaKERNEL/OS/Is_Command_Alias.ps1 | 39 ++++++++++ .../HestiaKERNEL/OS/Is_Command_Alias.sh | 39 ++++++++++ .../HestiaKERNEL/OS/Is_Command_Available.ps1 | 37 +++++++++ .../HestiaKERNEL/OS/Is_Command_Available.sh | 39 ++++++++++ .../HestiaKERNEL/OS/Is_Command_Builtin.ps1 | 39 ++++++++++ .../HestiaKERNEL/OS/Is_Command_Builtin.sh | 39 ++++++++++ .../HestiaKERNEL/OS/Is_Command_External.ps1 | 39 ++++++++++ .../HestiaKERNEL/OS/Is_Command_External.sh | 45 +++++++++++ .../HestiaKERNEL/OS/Is_Command_Function.ps1 | 39 ++++++++++ .../HestiaKERNEL/OS/Is_Command_Function.sh | 39 ++++++++++ Shell/tests/OS/Is_Command_Alias/0.ps1 | 70 +++++++++++++++++ Shell/tests/OS/Is_Command_Alias/0.sh | 74 ++++++++++++++++++ Shell/tests/OS/Is_Command_Alias/1.ps1 | 70 +++++++++++++++++ Shell/tests/OS/Is_Command_Alias/1.sh | 74 ++++++++++++++++++ Shell/tests/OS/Is_Command_Alias/2.ps1 | 70 +++++++++++++++++ Shell/tests/OS/Is_Command_Alias/2.sh | 74 ++++++++++++++++++ Shell/tests/OS/Is_Command_Available/0.ps1 | 69 +++++++++++++++++ Shell/tests/OS/Is_Command_Available/0.sh | 75 +++++++++++++++++++ Shell/tests/OS/Is_Command_Available/1.ps1 | 69 +++++++++++++++++ Shell/tests/OS/Is_Command_Available/1.sh | 75 +++++++++++++++++++ Shell/tests/OS/Is_Command_Available/2.ps1 | 69 +++++++++++++++++ Shell/tests/OS/Is_Command_Available/2.sh | 75 +++++++++++++++++++ Shell/tests/OS/Is_Command_Builtin/0.ps1 | 69 +++++++++++++++++ Shell/tests/OS/Is_Command_Builtin/0.sh | 73 ++++++++++++++++++ Shell/tests/OS/Is_Command_Builtin/1.ps1 | 69 +++++++++++++++++ Shell/tests/OS/Is_Command_Builtin/1.sh | 73 ++++++++++++++++++ Shell/tests/OS/Is_Command_Builtin/2.ps1 | 69 +++++++++++++++++ Shell/tests/OS/Is_Command_Builtin/2.sh | 73 ++++++++++++++++++ Shell/tests/OS/Is_Command_External/0.ps1 | 69 +++++++++++++++++ Shell/tests/OS/Is_Command_External/0.sh | 73 ++++++++++++++++++ Shell/tests/OS/Is_Command_External/1.ps1 | 69 +++++++++++++++++ Shell/tests/OS/Is_Command_External/1.sh | 73 ++++++++++++++++++ Shell/tests/OS/Is_Command_External/2.ps1 | 69 +++++++++++++++++ Shell/tests/OS/Is_Command_External/2.sh | 73 ++++++++++++++++++ Shell/tests/OS/Is_Command_Function/0.ps1 | 69 +++++++++++++++++ Shell/tests/OS/Is_Command_Function/0.sh | 73 ++++++++++++++++++ Shell/tests/OS/Is_Command_Function/1.ps1 | 69 +++++++++++++++++ Shell/tests/OS/Is_Command_Function/1.sh | 73 ++++++++++++++++++ Shell/tests/OS/Is_Command_Function/2.ps1 | 69 +++++++++++++++++ Shell/tests/OS/Is_Command_Function/2.sh | 73 ++++++++++++++++++ 40 files changed, 2536 insertions(+) create mode 100644 Shell/libraries/HestiaKERNEL/OS/Is_Command_Alias.ps1 create mode 100644 Shell/libraries/HestiaKERNEL/OS/Is_Command_Alias.sh create mode 100644 Shell/libraries/HestiaKERNEL/OS/Is_Command_Available.ps1 create mode 100644 Shell/libraries/HestiaKERNEL/OS/Is_Command_Available.sh create mode 100644 Shell/libraries/HestiaKERNEL/OS/Is_Command_Builtin.ps1 create mode 100644 Shell/libraries/HestiaKERNEL/OS/Is_Command_Builtin.sh create mode 100644 Shell/libraries/HestiaKERNEL/OS/Is_Command_External.ps1 create mode 100644 Shell/libraries/HestiaKERNEL/OS/Is_Command_External.sh create mode 100644 Shell/libraries/HestiaKERNEL/OS/Is_Command_Function.ps1 create mode 100644 Shell/libraries/HestiaKERNEL/OS/Is_Command_Function.sh create mode 100755 Shell/tests/OS/Is_Command_Alias/0.ps1 create mode 100755 Shell/tests/OS/Is_Command_Alias/0.sh create mode 100755 Shell/tests/OS/Is_Command_Alias/1.ps1 create mode 100755 Shell/tests/OS/Is_Command_Alias/1.sh create mode 100755 Shell/tests/OS/Is_Command_Alias/2.ps1 create mode 100755 Shell/tests/OS/Is_Command_Alias/2.sh create mode 100755 Shell/tests/OS/Is_Command_Available/0.ps1 create mode 100755 Shell/tests/OS/Is_Command_Available/0.sh create mode 100755 Shell/tests/OS/Is_Command_Available/1.ps1 create mode 100755 Shell/tests/OS/Is_Command_Available/1.sh create mode 100755 Shell/tests/OS/Is_Command_Available/2.ps1 create mode 100755 Shell/tests/OS/Is_Command_Available/2.sh create mode 100755 Shell/tests/OS/Is_Command_Builtin/0.ps1 create mode 100755 Shell/tests/OS/Is_Command_Builtin/0.sh create mode 100755 Shell/tests/OS/Is_Command_Builtin/1.ps1 create mode 100755 Shell/tests/OS/Is_Command_Builtin/1.sh create mode 100755 Shell/tests/OS/Is_Command_Builtin/2.ps1 create mode 100755 Shell/tests/OS/Is_Command_Builtin/2.sh create mode 100755 Shell/tests/OS/Is_Command_External/0.ps1 create mode 100755 Shell/tests/OS/Is_Command_External/0.sh create mode 100755 Shell/tests/OS/Is_Command_External/1.ps1 create mode 100755 Shell/tests/OS/Is_Command_External/1.sh create mode 100755 Shell/tests/OS/Is_Command_External/2.ps1 create mode 100755 Shell/tests/OS/Is_Command_External/2.sh create mode 100755 Shell/tests/OS/Is_Command_Function/0.ps1 create mode 100755 Shell/tests/OS/Is_Command_Function/0.sh create mode 100755 Shell/tests/OS/Is_Command_Function/1.ps1 create mode 100755 Shell/tests/OS/Is_Command_Function/1.sh create mode 100755 Shell/tests/OS/Is_Command_Function/2.ps1 create mode 100755 Shell/tests/OS/Is_Command_Function/2.sh diff --git a/Shell/libraries/HestiaKERNEL/OS/Is_Command_Alias.ps1 b/Shell/libraries/HestiaKERNEL/OS/Is_Command_Alias.ps1 new file mode 100644 index 0000000..ff24abf --- /dev/null +++ b/Shell/libraries/HestiaKERNEL/OS/Is_Command_Alias.ps1 @@ -0,0 +1,39 @@ +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +. "${env:LIBS_HESTIA}\HestiaKERNEL\Errors\Error_Codes.ps1" + + + + +function HestiaKERNEL-Is-Command-Alias-OS { + param ( + [string]$___command + ) + + + # validate input + if ($___command -eq "") { + return ${env:HestiaKERNEL_ERROR_DATA_MISSING} + } + + + # execute + $___process = Get-Command $___command ` + -CommandType Alias ` + -ErrorAction SilentlyContinue + if ($___process) { + return ${env:HestiaKERNEL_ERROR_OK} + } + + + # report status + return ${env:HestiaKERNEL_ERROR_DATA_MISSING} +} diff --git a/Shell/libraries/HestiaKERNEL/OS/Is_Command_Alias.sh b/Shell/libraries/HestiaKERNEL/OS/Is_Command_Alias.sh new file mode 100644 index 0000000..4644722 --- /dev/null +++ b/Shell/libraries/HestiaKERNEL/OS/Is_Command_Alias.sh @@ -0,0 +1,39 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +. "${LIBS_HESTIA}/HestiaKERNEL/Errors/Error_Codes.sh" + + + + +HestiaKERNEL_Is_Command_Alias_OS() { + #___command="$1" + + + # validate input + if [ "$1" = "" ]; then + printf -- "%d" $HestiaKERNEL_ERROR_DATA_MISSING + return $HestiaKERNEL_ERROR_DATA_MISSING + fi + + + # execute + ___ret="$(2>&1 type "$1")" + if [ ! "${___ret##*alias}" = "$___ret" ]; then + printf -- "%d" $HestiaKERNEL_ERROR_OK + return $HestiaKERNEL_ERROR_OK + fi + + + # report status + printf -- "%d" $HestiaKERNEL_ERROR_DATA_MISSING + return $HestiaKERNEL_ERROR_DATA_MISSING +} diff --git a/Shell/libraries/HestiaKERNEL/OS/Is_Command_Available.ps1 b/Shell/libraries/HestiaKERNEL/OS/Is_Command_Available.ps1 new file mode 100644 index 0000000..44fe7bd --- /dev/null +++ b/Shell/libraries/HestiaKERNEL/OS/Is_Command_Available.ps1 @@ -0,0 +1,37 @@ +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +. "${env:LIBS_HESTIA}\HestiaKERNEL\Errors\Error_Codes.ps1" + + + + +function HestiaKERNEL-Is-Command-Available-OS { + param ( + [string]$___command + ) + + + # validate input + if ($___command -eq "") { + return ${env:HestiaKERNEL_ERROR_DATA_MISSING} + } + + + # execute + $___process = Get-Command $___command -ErrorAction SilentlyContinue + if ($___process) { + return ${env:HestiaKERNEL_ERROR_OK} + } + + + # report status + return ${env:HestiaKERNEL_ERROR_DATA_MISSING} +} diff --git a/Shell/libraries/HestiaKERNEL/OS/Is_Command_Available.sh b/Shell/libraries/HestiaKERNEL/OS/Is_Command_Available.sh new file mode 100644 index 0000000..643fc39 --- /dev/null +++ b/Shell/libraries/HestiaKERNEL/OS/Is_Command_Available.sh @@ -0,0 +1,39 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +. "${LIBS_HESTIA}/HestiaKERNEL/Errors/Error_Codes.sh" + + + + +HestiaKERNEL_Is_Command_Available_OS() { + #___command="$1" + + + # validate input + if [ "$1" = "" ]; then + printf -- "%d" $HestiaKERNEL_ERROR_DATA_MISSING + return $HestiaKERNEL_ERROR_DATA_MISSING + fi + + + # execute + ___ret="$(2>&1 type "$1")" + if [ "${___ret##*not found}" = "$___ret" ]; then + printf -- "%d" $HestiaKERNEL_ERROR_OK + return $HestiaKERNEL_ERROR_OK + fi + + + # report status + printf -- "%d" $HestiaKERNEL_ERROR_DATA_MISSING + return $HestiaKERNEL_ERROR_DATA_MISSING +} diff --git a/Shell/libraries/HestiaKERNEL/OS/Is_Command_Builtin.ps1 b/Shell/libraries/HestiaKERNEL/OS/Is_Command_Builtin.ps1 new file mode 100644 index 0000000..aacfae6 --- /dev/null +++ b/Shell/libraries/HestiaKERNEL/OS/Is_Command_Builtin.ps1 @@ -0,0 +1,39 @@ +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +. "${env:LIBS_HESTIA}\HestiaKERNEL\Errors\Error_Codes.ps1" + + + + +function HestiaKERNEL-Is-Command-Builtin-OS { + param ( + [string]$___command + ) + + + # validate input + if ($___command -eq "") { + return ${env:HestiaKERNEL_ERROR_DATA_MISSING} + } + + + # execute + $___process = Get-Command $___command ` + -CommandType Cmdlet ` + -ErrorAction SilentlyContinue + if ($___process) { + return ${env:HestiaKERNEL_ERROR_OK} + } + + + # report status + return ${env:HestiaKERNEL_ERROR_DATA_MISSING} +} diff --git a/Shell/libraries/HestiaKERNEL/OS/Is_Command_Builtin.sh b/Shell/libraries/HestiaKERNEL/OS/Is_Command_Builtin.sh new file mode 100644 index 0000000..d8fe5e3 --- /dev/null +++ b/Shell/libraries/HestiaKERNEL/OS/Is_Command_Builtin.sh @@ -0,0 +1,39 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +. "${LIBS_HESTIA}/HestiaKERNEL/Errors/Error_Codes.sh" + + + + +HestiaKERNEL_Is_Command_Builtin_OS() { + #___command="$1" + + + # validate input + if [ "$1" = "" ]; then + printf -- "%d" $HestiaKERNEL_ERROR_DATA_MISSING + return $HestiaKERNEL_ERROR_DATA_MISSING + fi + + + # execute + ___ret="$(2>&1 type "$1")" + if [ ! "${___ret##*shell builtin}" = "$___ret" ]; then + printf -- "%d" $HestiaKERNEL_ERROR_OK + return $HestiaKERNEL_ERROR_OK + fi + + + # report status + printf -- "%d" $HestiaKERNEL_ERROR_DATA_MISSING + return $HestiaKERNEL_ERROR_DATA_MISSING +} diff --git a/Shell/libraries/HestiaKERNEL/OS/Is_Command_External.ps1 b/Shell/libraries/HestiaKERNEL/OS/Is_Command_External.ps1 new file mode 100644 index 0000000..8719967 --- /dev/null +++ b/Shell/libraries/HestiaKERNEL/OS/Is_Command_External.ps1 @@ -0,0 +1,39 @@ +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +. "${env:LIBS_HESTIA}\HestiaKERNEL\Errors\Error_Codes.ps1" + + + + +function HestiaKERNEL-Is-Command-External-OS { + param ( + [string]$___command + ) + + + # validate input + if ($___command -eq "") { + return ${env:HestiaKERNEL_ERROR_DATA_MISSING} + } + + + # execute + $___process = Get-Command $___command ` + -CommandType Application, ExternalScript, Script ` + -ErrorAction SilentlyContinue + if ($___process) { + return ${env:HestiaKERNEL_ERROR_OK} + } + + + # report status + return ${env:HestiaKERNEL_ERROR_DATA_MISSING} +} diff --git a/Shell/libraries/HestiaKERNEL/OS/Is_Command_External.sh b/Shell/libraries/HestiaKERNEL/OS/Is_Command_External.sh new file mode 100644 index 0000000..871ef53 --- /dev/null +++ b/Shell/libraries/HestiaKERNEL/OS/Is_Command_External.sh @@ -0,0 +1,45 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +. "${LIBS_HESTIA}/HestiaKERNEL/Errors/Error_Codes.sh" +. "${LIBS_HESTIA}/HestiaKERNEL/OS/Is_Command_Alias.sh" +. "${LIBS_HESTIA}/HestiaKERNEL/OS/Is_Command_Available.sh" +. "${LIBS_HESTIA}/HestiaKERNEL/OS/Is_Command_Builtin.sh" +. "${LIBS_HESTIA}/HestiaKERNEL/OS/Is_Command_Function.sh" + + + + +HestiaKERNEL_Is_Command_External_OS() { + #___command="$1" + + + # validate input + if [ "$1" = "" ]; then + printf -- "%d" $HestiaKERNEL_ERROR_DATA_MISSING + return $HestiaKERNEL_ERROR_DATA_MISSING + fi + + + # execute + if [ "$(HestiaKERNEL_Is_Command_Alias_OS "$1")" -ne $HestiaKERNEL_ERROR_OK ] && + [ "$(HestiaKERNEL_Is_Command_Builtin_OS "$1")" -ne $HestiaKERNEL_ERROR_OK ] && + [ "$(HestiaKERNEL_Is_Command_Function_OS "$1")" -ne $HestiaKERNEL_ERROR_OK ] && + [ "$(HestiaKERNEL_Is_Command_Available_OS "$1")" -eq $HestiaKERNEL_ERROR_OK ]; then + printf -- "%d" $HestiaKERNEL_ERROR_OK + return $HestiaKERNEL_ERROR_OK + fi + + + # report status + printf -- "%d" $HestiaKERNEL_ERROR_DATA_MISSING + return $HestiaKERNEL_ERROR_DATA_MISSING +} diff --git a/Shell/libraries/HestiaKERNEL/OS/Is_Command_Function.ps1 b/Shell/libraries/HestiaKERNEL/OS/Is_Command_Function.ps1 new file mode 100644 index 0000000..06951df --- /dev/null +++ b/Shell/libraries/HestiaKERNEL/OS/Is_Command_Function.ps1 @@ -0,0 +1,39 @@ +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +. "${env:LIBS_HESTIA}\HestiaKERNEL\Errors\Error_Codes.ps1" + + + + +function HestiaKERNEL-Is-Command-Function-OS { + param ( + [string]$___command + ) + + + # validate input + if ($___command -eq "") { + return ${env:HestiaKERNEL_ERROR_DATA_MISSING} + } + + + # execute + $___process = Get-Command $___command ` + -CommandType Function ` + -ErrorAction SilentlyContinue + if ($___process) { + return ${env:HestiaKERNEL_ERROR_OK} + } + + + # report status + return ${env:HestiaKERNEL_ERROR_DATA_MISSING} +} diff --git a/Shell/libraries/HestiaKERNEL/OS/Is_Command_Function.sh b/Shell/libraries/HestiaKERNEL/OS/Is_Command_Function.sh new file mode 100644 index 0000000..146e973 --- /dev/null +++ b/Shell/libraries/HestiaKERNEL/OS/Is_Command_Function.sh @@ -0,0 +1,39 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +. "${LIBS_HESTIA}/HestiaKERNEL/Errors/Error_Codes.sh" + + + + +HestiaKERNEL_Is_Command_Function_OS() { + #___command="$1" + + + # validate input + if [ "$1" = "" ]; then + printf -- "%d" $HestiaKERNEL_ERROR_DATA_MISSING + return $HestiaKERNEL_ERROR_DATA_MISSING + fi + + + # execute + ___ret="$(2>&1 type "$1")" + if [ ! "${___ret##*shell function}" = "$___ret" ]; then + printf -- "%d" $HestiaKERNEL_ERROR_OK + return $HestiaKERNEL_ERROR_OK + fi + + + # report status + printf -- "%d" $HestiaKERNEL_ERROR_DATA_MISSING + return $HestiaKERNEL_ERROR_DATA_MISSING +} diff --git a/Shell/tests/OS/Is_Command_Alias/0.ps1 b/Shell/tests/OS/Is_Command_Alias/0.ps1 new file mode 100755 index 0000000..6737fad --- /dev/null +++ b/Shell/tests/OS/Is_Command_Alias/0.ps1 @@ -0,0 +1,70 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +$null = Write-Host @" +TEST CASE : +HestiaKERNEL-Is-Command-Alias + +DESCRIPTION: +Function can identify a proper alias. + +"@ + + + + +$null = Write-Host "Checking LIBS_HESTIA pathing: (${env:LIBS_HESTIA})" +if ("${env:LIBS_HESTIA}" -eq "") { + $null = Write-Host "[ FAILED ] variable undefined!`n" + exit 1 +} + + + + +$___target = "${env:LIBS_HESTIA}\HestiaKERNEL\OS\Is_Command_Alias.ps1" +$null = Write-Host "Checking Library file (${___target})..." +if (-not (Test-Path -Path $___target)) { + $null = Write-Host "[ FAILED ] missing file!`n" + exit 1 +} + + + + +$null = Write-Host "Import function library..." +$null = . $___target +if (-not (Get-Command 'HestiaKERNEL-Is-Command-Alias-OS' -errorAction SilentlyContinue)) { + $null = Write-Host "[ FAILED ] error on import!`n" + exit 1 +} + + + + +$___input = "aebaebatrb" +$null = New-Alias -Name $___input -Value dir +$___expect = 0 +$___output = HestiaKERNEL-Is-Command-Alias-OS $___input +$null = Write-Host "Given input :`n|${___input}|`n" +$null = Write-Host "Given expect :`n|${___expect}|`n" +$null = Write-Host "Got Output :`n|${___output}|`n" + + + + +# assert result +if ("${___output}" -eq "${___expect}") { + $null = Write-Host "[ PASSED ]" + exit 0 +} +$null = Write-Host "[ FAILED ] unexpected/inconsistent output!" +exit 1 diff --git a/Shell/tests/OS/Is_Command_Alias/0.sh b/Shell/tests/OS/Is_Command_Alias/0.sh new file mode 100755 index 0000000..e4570a8 --- /dev/null +++ b/Shell/tests/OS/Is_Command_Alias/0.sh @@ -0,0 +1,74 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +1>&2 printf -- "%s\n" "\ +TEST CASE : +HestiaKERNEL_Is_Command_Alias + +DESCRIPTION: +Function can identify a proper alias. +" + + + + +1>&2 printf -- "Checking LIBS_HESTIA pathing: (%s)\n" "$LIBS_HESTIA" +if [ "$LIBS_HESTIA" = "" ]; then + 1>&2 printf -- "[ FAILED ] variable undefined!\n" + exit 1 +fi + + + + +___target="${LIBS_HESTIA}/HestiaKERNEL/OS/Is_Command_Alias.sh" +1>&2 printf -- "Checking Library file (%s)\n" "$___target" +if [ ! -f "$___target" ]; then + 1>&2 printf -- "[ FAILED ] missing file!\n" + exit 1 +fi + + + + +1>&2 printf -- "Import function library...\n" +. "$___target" +___target="$(type HestiaKERNEL_Is_Command_Alias_OS)" +if [ ! "${___target##*not found}" = "$___target" ]; then + 1>&2 printf -- "[ FAILED ] error on import!\n" + exit 1 +fi + + + + +___input="aebaebatrb" +alias aebaebatrb=dd +1>&2 printf -- "Given input :\n|%s|\n\n" "$___input" + +___expect="0" +1>&2 printf -- "Given expect :\n|%s|\n\n" "$___expect" + +___output="$(HestiaKERNEL_Is_Command_Alias_OS "$___input")" +___process=$? +1>&2 printf -- "Given output :\n|%s|\n\n" "$___output" +1>&2 printf -- "Given exit code :\n|%s|\n\n" "$___process" + + + + +# assert result +if [ "$___output" = "$___expect" ]; then + 1>&2 printf -- "[ PASSED ]\n" + exit 0 +fi +1>&2 printf -- "[ FAILED ] unexpected/inconsistent output!\n" +exit 1 diff --git a/Shell/tests/OS/Is_Command_Alias/1.ps1 b/Shell/tests/OS/Is_Command_Alias/1.ps1 new file mode 100755 index 0000000..2098342 --- /dev/null +++ b/Shell/tests/OS/Is_Command_Alias/1.ps1 @@ -0,0 +1,70 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +$null = Write-Host @" +TEST CASE : +HestiaKERNEL-Is-Command-Alias + +DESCRIPTION: +Function can identify a proper alias. + +"@ + + + + +$null = Write-Host "Checking LIBS_HESTIA pathing: (${env:LIBS_HESTIA})" +if ("${env:LIBS_HESTIA}" -eq "") { + $null = Write-Host "[ FAILED ] variable undefined!`n" + exit 1 +} + + + + +$___target = "${env:LIBS_HESTIA}\HestiaKERNEL\OS\Is_Command_Alias.ps1" +$null = Write-Host "Checking Library file (${___target})..." +if (-not (Test-Path -Path $___target)) { + $null = Write-Host "[ FAILED ] missing file!`n" + exit 1 +} + + + + +$null = Write-Host "Import function library..." +$null = . $___target +if (-not (Get-Command 'HestiaKERNEL-Is-Command-Alias-OS' -errorAction SilentlyContinue)) { + $null = Write-Host "[ FAILED ] error on import!`n" + exit 1 +} + + + + +$___input = "" +$null = New-Alias -Name aebaebatrb -Value dir +$___expect = 0 +$___output = HestiaKERNEL-Is-Command-Alias-OS $___input +$null = Write-Host "Given input :`n|${___input}|`n" +$null = Write-Host "Given expect :`n|${___expect}|`n" +$null = Write-Host "Got Output :`n|${___output}|`n" + + + + +# assert result +if ("${___output}" -ne "${___expect}") { + $null = Write-Host "[ PASSED ]" + exit 0 +} +$null = Write-Host "[ FAILED ] unexpected/inconsistent output!" +exit 1 diff --git a/Shell/tests/OS/Is_Command_Alias/1.sh b/Shell/tests/OS/Is_Command_Alias/1.sh new file mode 100755 index 0000000..2f6eb29 --- /dev/null +++ b/Shell/tests/OS/Is_Command_Alias/1.sh @@ -0,0 +1,74 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +1>&2 printf -- "%s\n" "\ +TEST CASE : +HestiaKERNEL_Is_Command_Alias + +DESCRIPTION: +Function can identify an empty alias. +" + + + + +1>&2 printf -- "Checking LIBS_HESTIA pathing: (%s)\n" "$LIBS_HESTIA" +if [ "$LIBS_HESTIA" = "" ]; then + 1>&2 printf -- "[ FAILED ] variable undefined!\n" + exit 1 +fi + + + + +___target="${LIBS_HESTIA}/HestiaKERNEL/OS/Is_Command_Alias.sh" +1>&2 printf -- "Checking Library file (%s)\n" "$___target" +if [ ! -f "$___target" ]; then + 1>&2 printf -- "[ FAILED ] missing file!\n" + exit 1 +fi + + + + +1>&2 printf -- "Import function library...\n" +. "$___target" +___target="$(type HestiaKERNEL_Is_Command_Alias_OS)" +if [ ! "${___target##*not found}" = "$___target" ]; then + 1>&2 printf -- "[ FAILED ] error on import!\n" + exit 1 +fi + + + + +___input="" +alias aebaebatrb=dd +1>&2 printf -- "Given input :\n|%s|\n\n" "$___input" + +___expect="0" +1>&2 printf -- "Given expect :\n|not %s|\n\n" "$___expect" + +___output="$(HestiaKERNEL_Is_Command_Alias_OS "$___input")" +___process=$? +1>&2 printf -- "Given output :\n|%s|\n\n" "$___output" +1>&2 printf -- "Given exit code :\n|%s|\n\n" "$___process" + + + + +# assert result +if [ ! "$___output" = "$___expect" ]; then + 1>&2 printf -- "[ PASSED ]\n" + exit 0 +fi +1>&2 printf -- "[ FAILED ] unexpected/inconsistent output!\n" +exit 1 diff --git a/Shell/tests/OS/Is_Command_Alias/2.ps1 b/Shell/tests/OS/Is_Command_Alias/2.ps1 new file mode 100755 index 0000000..b24159d --- /dev/null +++ b/Shell/tests/OS/Is_Command_Alias/2.ps1 @@ -0,0 +1,70 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +$null = Write-Host @" +TEST CASE : +HestiaKERNEL-Is-Command-Alias + +DESCRIPTION: +Function can identify an invalid alias. + +"@ + + + + +$null = Write-Host "Checking LIBS_HESTIA pathing: (${env:LIBS_HESTIA})" +if ("${env:LIBS_HESTIA}" -eq "") { + $null = Write-Host "[ FAILED ] variable undefined!`n" + exit 1 +} + + + + +$___target = "${env:LIBS_HESTIA}\HestiaKERNEL\OS\Is_Command_Alias.ps1" +$null = Write-Host "Checking Library file (${___target})..." +if (-not (Test-Path -Path $___target)) { + $null = Write-Host "[ FAILED ] missing file!`n" + exit 1 +} + + + + +$null = Write-Host "Import function library..." +$null = . $___target +if (-not (Get-Command 'HestiaKERNEL-Is-Command-Alias-OS' -errorAction SilentlyContinue)) { + $null = Write-Host "[ FAILED ] error on import!`n" + exit 1 +} + + + + +$___input = "thntlhlfvbrt" +$null = New-Alias -Name aebaebatrb -Value dir +$___expect = 0 +$___output = HestiaKERNEL-Is-Command-Alias-OS $___input +$null = Write-Host "Given input :`n|${___input}|`n" +$null = Write-Host "Given expect :`n|not ${___expect}|`n" +$null = Write-Host "Got Output :`n|${___output}|`n" + + + + +# assert result +if ("${___output}" -ne "${___expect}") { + $null = Write-Host "[ PASSED ]" + exit 0 +} +$null = Write-Host "[ FAILED ] unexpected/inconsistent output!" +exit 1 diff --git a/Shell/tests/OS/Is_Command_Alias/2.sh b/Shell/tests/OS/Is_Command_Alias/2.sh new file mode 100755 index 0000000..e59a0a2 --- /dev/null +++ b/Shell/tests/OS/Is_Command_Alias/2.sh @@ -0,0 +1,74 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +1>&2 printf -- "%s\n" "\ +TEST CASE : +HestiaKERNEL_Is_Command_Alias + +DESCRIPTION: +Function can identify an invalid alias. +" + + + + +1>&2 printf -- "Checking LIBS_HESTIA pathing: (%s)\n" "$LIBS_HESTIA" +if [ "$LIBS_HESTIA" = "" ]; then + 1>&2 printf -- "[ FAILED ] variable undefined!\n" + exit 1 +fi + + + + +___target="${LIBS_HESTIA}/HestiaKERNEL/OS/Is_Command_Alias.sh" +1>&2 printf -- "Checking Library file (%s)\n" "$___target" +if [ ! -f "$___target" ]; then + 1>&2 printf -- "[ FAILED ] missing file!\n" + exit 1 +fi + + + + +1>&2 printf -- "Import function library...\n" +. "$___target" +___target="$(type HestiaKERNEL_Is_Command_Alias_OS)" +if [ ! "${___target##*not found}" = "$___target" ]; then + 1>&2 printf -- "[ FAILED ] error on import!\n" + exit 1 +fi + + + + +___input="thntlhlfvbrt" +alias aebaebatrb=dd +1>&2 printf -- "Given input :\n|%s|\n\n" "$___input" + +___expect="0" +1>&2 printf -- "Given expect :\n|not %s|\n\n" "$___expect" + +___output="$(HestiaKERNEL_Is_Command_Alias_OS "$___input")" +___process=$? +1>&2 printf -- "Given output :\n|%s|\n\n" "$___output" +1>&2 printf -- "Given exit code :\n|%s|\n\n" "$___process" + + + + +# assert result +if [ ! "$___output" = "$___expect" ]; then + 1>&2 printf -- "[ PASSED ]\n" + exit 0 +fi +1>&2 printf -- "[ FAILED ] unexpected/inconsistent output!\n" +exit 1 diff --git a/Shell/tests/OS/Is_Command_Available/0.ps1 b/Shell/tests/OS/Is_Command_Available/0.ps1 new file mode 100755 index 0000000..8607e66 --- /dev/null +++ b/Shell/tests/OS/Is_Command_Available/0.ps1 @@ -0,0 +1,69 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +$null = Write-Host @" +TEST CASE : +HestiaKERNEL-Is-Command-Available + +DESCRIPTION: +Function can identify a proper input. + +"@ + + + + +$null = Write-Host "Checking LIBS_HESTIA pathing: (${env:LIBS_HESTIA})" +if ("${env:LIBS_HESTIA}" -eq "") { + $null = Write-Host "[ FAILED ] variable undefined!`n" + exit 1 +} + + + + +$___target = "${env:LIBS_HESTIA}\HestiaKERNEL\OS\Is_Command_Available.ps1" +$null = Write-Host "Checking Library file (${___target})..." +if (-not (Test-Path -Path $___target)) { + $null = Write-Host "[ FAILED ] missing file!`n" + exit 1 +} + + + + +$null = Write-Host "Import function library..." +$null = . $___target +if (-not (Get-Command 'HestiaKERNEL-Is-Command-Available-OS' -errorAction SilentlyContinue)) { + $null = Write-Host "[ FAILED ] error on import!`n" + exit 1 +} + + + + +$___input = "Get-Command" +$___expect = 0 +$___output = HestiaKERNEL-Is-Command-Available-OS $___input +$null = Write-Host "Given input :`n|${___input}|`n" +$null = Write-Host "Given expect :`n|${___expect}|`n" +$null = Write-Host "Got Output :`n|${___output}|`n" + + + + +# assert result +if ("${___output}" -eq "${___expect}") { + $null = Write-Host "[ PASSED ]" + exit 0 +} +$null = Write-Host "[ FAILED ] unexpected/inconsistent output!" +exit 1 diff --git a/Shell/tests/OS/Is_Command_Available/0.sh b/Shell/tests/OS/Is_Command_Available/0.sh new file mode 100755 index 0000000..335c8ca --- /dev/null +++ b/Shell/tests/OS/Is_Command_Available/0.sh @@ -0,0 +1,75 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +1>&2 printf -- "%s\n" "\ +TEST CASE : +HestiaKERNEL_Is_Command_Available + +DESCRIPTION: +Function can identify a proper input. +" + + + + +1>&2 printf -- "Checking LIBS_HESTIA pathing: (%s)\n" "$LIBS_HESTIA" +if [ "$LIBS_HESTIA" = "" ]; then + 1>&2 printf -- "[ FAILED ] variable undefined!\n" + exit 1 +fi + + + + +___target="${LIBS_HESTIA}/HestiaKERNEL/OS/Is_Command_Available.sh" +1>&2 printf -- "Checking Library file (%s)\n" "$___target" +if [ ! -f "$___target" ]; then + 1>&2 printf -- "[ FAILED ] missing file!\n" + exit 1 +fi + + + + +1>&2 printf -- "Import function library...\n" +. "$___target" +___target="$(2>&1 type HestiaKERNEL_Is_Command_Available_OS)" +# NOTICE: use process code because MacOS can produce the entire function making +# the 'not found' function false positive. +if [ $? -ne 0 ]; then + 1>&2 printf -- "[ FAILED ] error on import!\n" + exit 1 +fi + + + + +___input="pwd" +1>&2 printf -- "Given input :\n|%s|\n\n" "$___input" + +___expect="0" +1>&2 printf -- "Given expect :\n|%s|\n\n" "$___expect" + +___output="$(HestiaKERNEL_Is_Command_Available_OS "$___input")" +___process=$? +1>&2 printf -- "Given output :\n|%s|\n\n" "$___output" +1>&2 printf -- "Given exit code :\n|%s|\n\n" "$___process" + + + + +# assert result +if [ "$___output" = "$___expect" ]; then + 1>&2 printf -- "[ PASSED ]\n" + exit 0 +fi +1>&2 printf -- "[ FAILED ] unexpected/inconsistent output!\n" +exit 1 diff --git a/Shell/tests/OS/Is_Command_Available/1.ps1 b/Shell/tests/OS/Is_Command_Available/1.ps1 new file mode 100755 index 0000000..667480e --- /dev/null +++ b/Shell/tests/OS/Is_Command_Available/1.ps1 @@ -0,0 +1,69 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +$null = Write-Host @" +TEST CASE : +HestiaKERNEL-Is-Command-Available + +DESCRIPTION: +Function can identify an empty input. + +"@ + + + + +$null = Write-Host "Checking LIBS_HESTIA pathing: (${env:LIBS_HESTIA})" +if ("${env:LIBS_HESTIA}" -eq "") { + $null = Write-Host "[ FAILED ] variable undefined!`n" + exit 1 +} + + + + +$___target = "${env:LIBS_HESTIA}\HestiaKERNEL\OS\Is_Command_Available.ps1" +$null = Write-Host "Checking Library file (${___target})..." +if (-not (Test-Path -Path $___target)) { + $null = Write-Host "[ FAILED ] missing file!`n" + exit 1 +} + + + + +$null = Write-Host "Import function library..." +$null = . $___target +if (-not (Get-Command 'HestiaKERNEL-Is-Command-Available-OS' -errorAction SilentlyContinue)) { + $null = Write-Host "[ FAILED ] error on import!`n" + exit 1 +} + + + + +$___input = "" +$___expect = 0 +$___output = HestiaKERNEL-Is-Command-Available-OS $___input +$null = Write-Host "Given input :`n|${___input}|`n" +$null = Write-Host "Given expect :`n|not ${___expect}|`n" +$null = Write-Host "Got Output :`n|${___output}|`n" + + + + +# assert result +if ("${___output}" -ne "${___expect}") { + $null = Write-Host "[ PASSED ]" + exit 0 +} +$null = Write-Host "[ FAILED ] unexpected/inconsistent output!" +exit 1 diff --git a/Shell/tests/OS/Is_Command_Available/1.sh b/Shell/tests/OS/Is_Command_Available/1.sh new file mode 100755 index 0000000..1624289 --- /dev/null +++ b/Shell/tests/OS/Is_Command_Available/1.sh @@ -0,0 +1,75 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +1>&2 printf -- "%s\n" "\ +TEST CASE : +HestiaKERNEL_Is_Command_Available + +DESCRIPTION: +Function can identify an empty input. +" + + + + +1>&2 printf -- "Checking LIBS_HESTIA pathing: (%s)\n" "$LIBS_HESTIA" +if [ "$LIBS_HESTIA" = "" ]; then + 1>&2 printf -- "[ FAILED ] variable undefined!\n" + exit 1 +fi + + + + +___target="${LIBS_HESTIA}/HestiaKERNEL/OS/Is_Command_Available.sh" +1>&2 printf -- "Checking Library file (%s)\n" "$___target" +if [ ! -f "$___target" ]; then + 1>&2 printf -- "[ FAILED ] missing file!\n" + exit 1 +fi + + + + +1>&2 printf -- "Import function library...\n" +. "$___target" +___target="$(type HestiaKERNEL_Is_Command_Available_OS)" +# NOTICE: use process code because MacOS can produce the entire function making +# the 'not found' function false positive. +if [ $? -ne 0 ]; then + 1>&2 printf -- "[ FAILED ] error on import!\n" + exit 1 +fi + + + + +___input="" +1>&2 printf -- "Given input :\n|%s|\n\n" "$___input" + +___expect="0" +1>&2 printf -- "Given expect :\n|not %s|\n\n" "$___expect" + +___output="$(HestiaKERNEL_Is_Command_Available_OS "$___input")" +___process=$? +1>&2 printf -- "Given output :\n|%s|\n\n" "$___output" +1>&2 printf -- "Given exit code :\n|%s|\n\n" "$___process" + + + + +# assert result +if [ ! "$___output" = "$___expect" ]; then + 1>&2 printf -- "[ PASSED ]\n" + exit 0 +fi +1>&2 printf -- "[ FAILED ] unexpected/inconsistent output!\n" +exit 1 diff --git a/Shell/tests/OS/Is_Command_Available/2.ps1 b/Shell/tests/OS/Is_Command_Available/2.ps1 new file mode 100755 index 0000000..8599120 --- /dev/null +++ b/Shell/tests/OS/Is_Command_Available/2.ps1 @@ -0,0 +1,69 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +$null = Write-Host @" +TEST CASE : +HestiaKERNEL-Is-Command-Available + +DESCRIPTION: +Function can identify an invalid input. + +"@ + + + + +$null = Write-Host "Checking LIBS_HESTIA pathing: (${env:LIBS_HESTIA})" +if ("${env:LIBS_HESTIA}" -eq "") { + $null = Write-Host "[ FAILED ] variable undefined!`n" + exit 1 +} + + + + +$___target = "${env:LIBS_HESTIA}\HestiaKERNEL\OS\Is_Command_Available.ps1" +$null = Write-Host "Checking Library file (${___target})..." +if (-not (Test-Path -Path $___target)) { + $null = Write-Host "[ FAILED ] missing file!`n" + exit 1 +} + + + + +$null = Write-Host "Import function library..." +$null = . $___target +if (-not (Get-Command 'HestiaKERNEL-Is-Command-Available-OS' -errorAction SilentlyContinue)) { + $null = Write-Host "[ FAILED ] error on import!`n" + exit 1 +} + + + + +$___input = "aewrbaebebrtsa" +$___expect = 0 +$___output = HestiaKERNEL-Is-Command-Available-OS $___input +$null = Write-Host "Given input :`n|${___input}|`n" +$null = Write-Host "Given expect :`n|not ${___expect}|`n" +$null = Write-Host "Got Output :`n|${___output}|`n" + + + + +# assert result +if ("${___output}" -ne "${___expect}") { + $null = Write-Host "[ PASSED ]" + exit 0 +} +$null = Write-Host "[ FAILED ] unexpected/inconsistent output!" +exit 1 diff --git a/Shell/tests/OS/Is_Command_Available/2.sh b/Shell/tests/OS/Is_Command_Available/2.sh new file mode 100755 index 0000000..ec66228 --- /dev/null +++ b/Shell/tests/OS/Is_Command_Available/2.sh @@ -0,0 +1,75 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +1>&2 printf -- "%s\n" "\ +TEST CASE : +HestiaKERNEL_Is_Command_Available + +DESCRIPTION: +Function can identify an invalid input. +" + + + + +1>&2 printf -- "Checking LIBS_HESTIA pathing: (%s)\n" "$LIBS_HESTIA" +if [ "$LIBS_HESTIA" = "" ]; then + 1>&2 printf -- "[ FAILED ] variable undefined!\n" + exit 1 +fi + + + + +___target="${LIBS_HESTIA}/HestiaKERNEL/OS/Is_Command_Available.sh" +1>&2 printf -- "Checking Library file (%s)\n" "$___target" +if [ ! -f "$___target" ]; then + 1>&2 printf -- "[ FAILED ] missing file!\n" + exit 1 +fi + + + + +1>&2 printf -- "Import function library...\n" +. "$___target" +___target="$(2>&1 type HestiaKERNEL_Is_Command_Available_OS)" +# NOTICE: use process code because MacOS can produce the entire function making +# the 'not found' function false positive. +if [ $? -ne 0 ]; then + 1>&2 printf -- "[ FAILED ] error on import!\n" + exit 1 +fi + + + + +___input="aewrbaebebrtsa" +1>&2 printf -- "Given input :\n|%s|\n\n" "$___input" + +___expect="0" +1>&2 printf -- "Given expect :\n|not %s|\n\n" "$___expect" + +___output="$(HestiaKERNEL_Is_Command_Available_OS "$___input")" +___process=$? +1>&2 printf -- "Given output :\n|%s|\n\n" "$___output" +1>&2 printf -- "Given exit code :\n|%s|\n\n" "$___process" + + + + +# assert result +if [ ! "$___output" = "$___expect" ]; then + 1>&2 printf -- "[ PASSED ]\n" + exit 0 +fi +1>&2 printf -- "[ FAILED ] unexpected/inconsistent output!\n" +exit 1 diff --git a/Shell/tests/OS/Is_Command_Builtin/0.ps1 b/Shell/tests/OS/Is_Command_Builtin/0.ps1 new file mode 100755 index 0000000..e0315c2 --- /dev/null +++ b/Shell/tests/OS/Is_Command_Builtin/0.ps1 @@ -0,0 +1,69 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +$null = Write-Host @" +TEST CASE : +HestiaKERNEL-Is-Command-Builtin + +DESCRIPTION: +Function can identify a proper cmdlet. + +"@ + + + + +$null = Write-Host "Checking LIBS_HESTIA pathing: (${env:LIBS_HESTIA})" +if ("${env:LIBS_HESTIA}" -eq "") { + $null = Write-Host "[ FAILED ] variable undefined!`n" + exit 1 +} + + + + +$___target = "${env:LIBS_HESTIA}\HestiaKERNEL\OS\Is_Command_Builtin.ps1" +$null = Write-Host "Checking Library file (${___target})..." +if (-not (Test-Path -Path $___target)) { + $null = Write-Host "[ FAILED ] missing file!`n" + exit 1 +} + + + + +$null = Write-Host "Import function library..." +$null = . $___target +if (-not (Get-Command 'HestiaKERNEL-Is-Command-Builtin-OS' -errorAction SilentlyContinue)) { + $null = Write-Host "[ FAILED ] error on import!`n" + exit 1 +} + + + + +$___input = "Get-Command" +$___expect = 0 +$___output = HestiaKERNEL-Is-Command-Builtin-OS $___input +$null = Write-Host "Given input :`n|${___input}|`n" +$null = Write-Host "Given expect :`n|${___expect}|`n" +$null = Write-Host "Got Output :`n|${___output}|`n" + + + + +# assert result +if ("${___output}" -eq "${___expect}") { + $null = Write-Host "[ PASSED ]" + exit 0 +} +$null = Write-Host "[ FAILED ] unexpected/inconsistent output!" +exit 1 diff --git a/Shell/tests/OS/Is_Command_Builtin/0.sh b/Shell/tests/OS/Is_Command_Builtin/0.sh new file mode 100755 index 0000000..f80cc47 --- /dev/null +++ b/Shell/tests/OS/Is_Command_Builtin/0.sh @@ -0,0 +1,73 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +1>&2 printf -- "%s\n" "\ +TEST CASE : +HestiaKERNEL_Is_Command_Builtin + +DESCRIPTION: +Function can identify a proper shell builtin. +" + + + + +1>&2 printf -- "Checking LIBS_HESTIA pathing: (%s)\n" "$LIBS_HESTIA" +if [ "$LIBS_HESTIA" = "" ]; then + 1>&2 printf -- "[ FAILED ] variable undefined!\n" + exit 1 +fi + + + + +___target="${LIBS_HESTIA}/HestiaKERNEL/OS/Is_Command_Builtin.sh" +1>&2 printf -- "Checking Library file (%s)\n" "$___target" +if [ ! -f "$___target" ]; then + 1>&2 printf -- "[ FAILED ] missing file!\n" + exit 1 +fi + + + + +1>&2 printf -- "Import function library...\n" +. "$___target" +___target="$(type HestiaKERNEL_Is_Command_Builtin_OS)" +if [ ! "${___target##*not found}" = "$___target" ]; then + 1>&2 printf -- "[ FAILED ] error on import!\n" + exit 1 +fi + + + + +___input="pwd" +1>&2 printf -- "Given input :\n|%s|\n\n" "$___input" + +___expect="0" +1>&2 printf -- "Given expect :\n|%s|\n\n" "$___expect" + +___output="$(HestiaKERNEL_Is_Command_Builtin_OS "$___input")" +___process=$? +1>&2 printf -- "Given output :\n|%s|\n\n" "$___output" +1>&2 printf -- "Given exit code :\n|%s|\n\n" "$___process" + + + + +# assert result +if [ "$___output" = "$___expect" ]; then + 1>&2 printf -- "[ PASSED ]\n" + exit 0 +fi +1>&2 printf -- "[ FAILED ] unexpected/inconsistent output!\n" +exit 1 diff --git a/Shell/tests/OS/Is_Command_Builtin/1.ps1 b/Shell/tests/OS/Is_Command_Builtin/1.ps1 new file mode 100755 index 0000000..26e708c --- /dev/null +++ b/Shell/tests/OS/Is_Command_Builtin/1.ps1 @@ -0,0 +1,69 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +$null = Write-Host @" +TEST CASE : +HestiaKERNEL-Is-Command-Builtin + +DESCRIPTION: +Function can identify an empty cmdlet. + +"@ + + + + +$null = Write-Host "Checking LIBS_HESTIA pathing: (${env:LIBS_HESTIA})" +if ("${env:LIBS_HESTIA}" -eq "") { + $null = Write-Host "[ FAILED ] variable undefined!`n" + exit 1 +} + + + + +$___target = "${env:LIBS_HESTIA}\HestiaKERNEL\OS\Is_Command_Builtin.ps1" +$null = Write-Host "Checking Library file (${___target})..." +if (-not (Test-Path -Path $___target)) { + $null = Write-Host "[ FAILED ] missing file!`n" + exit 1 +} + + + + +$null = Write-Host "Import function library..." +$null = . $___target +if (-not (Get-Command 'HestiaKERNEL-Is-Command-Builtin-OS' -errorAction SilentlyContinue)) { + $null = Write-Host "[ FAILED ] error on import!`n" + exit 1 +} + + + + +$___input = "" +$___expect = 0 +$___output = HestiaKERNEL-Is-Command-Builtin-OS $___input +$null = Write-Host "Given input :`n|${___input}|`n" +$null = Write-Host "Given expect :`n|${___expect}|`n" +$null = Write-Host "Got Output :`n|${___output}|`n" + + + + +# assert result +if ("${___output}" -ne "${___expect}") { + $null = Write-Host "[ PASSED ]" + exit 0 +} +$null = Write-Host "[ FAILED ] unexpected/inconsistent output!" +exit 1 diff --git a/Shell/tests/OS/Is_Command_Builtin/1.sh b/Shell/tests/OS/Is_Command_Builtin/1.sh new file mode 100755 index 0000000..9caee7d --- /dev/null +++ b/Shell/tests/OS/Is_Command_Builtin/1.sh @@ -0,0 +1,73 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +1>&2 printf -- "%s\n" "\ +TEST CASE : +HestiaKERNEL_Is_Command_Builtin + +DESCRIPTION: +Function can identify an empty shell builtin. +" + + + + +1>&2 printf -- "Checking LIBS_HESTIA pathing: (%s)\n" "$LIBS_HESTIA" +if [ "$LIBS_HESTIA" = "" ]; then + 1>&2 printf -- "[ FAILED ] variable undefined!\n" + exit 1 +fi + + + + +___target="${LIBS_HESTIA}/HestiaKERNEL/OS/Is_Command_Builtin.sh" +1>&2 printf -- "Checking Library file (%s)\n" "$___target" +if [ ! -f "$___target" ]; then + 1>&2 printf -- "[ FAILED ] missing file!\n" + exit 1 +fi + + + + +1>&2 printf -- "Import function library...\n" +. "$___target" +___target="$(type HestiaKERNEL_Is_Command_Builtin_OS)" +if [ ! "${___target##*not found}" = "$___target" ]; then + 1>&2 printf -- "[ FAILED ] error on import!\n" + exit 1 +fi + + + + +___input="" +1>&2 printf -- "Given input :\n|%s|\n\n" "$___input" + +___expect="0" +1>&2 printf -- "Given expect :\n|not %s|\n\n" "$___expect" + +___output="$(HestiaKERNEL_Is_Command_Builtin_OS "$___input")" +___process=$? +1>&2 printf -- "Given output :\n|%s|\n\n" "$___output" +1>&2 printf -- "Given exit code :\n|%s|\n\n" "$___process" + + + + +# assert result +if [ ! "$___output" = "$___expect" ]; then + 1>&2 printf -- "[ PASSED ]\n" + exit 0 +fi +1>&2 printf -- "[ FAILED ] unexpected/inconsistent output!\n" +exit 1 diff --git a/Shell/tests/OS/Is_Command_Builtin/2.ps1 b/Shell/tests/OS/Is_Command_Builtin/2.ps1 new file mode 100755 index 0000000..84d0a5c --- /dev/null +++ b/Shell/tests/OS/Is_Command_Builtin/2.ps1 @@ -0,0 +1,69 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +$null = Write-Host @" +TEST CASE : +HestiaKERNEL-Is-Command-Builtin + +DESCRIPTION: +Function can identify an invalid cmdlet. + +"@ + + + + +$null = Write-Host "Checking LIBS_HESTIA pathing: (${env:LIBS_HESTIA})" +if ("${env:LIBS_HESTIA}" -eq "") { + $null = Write-Host "[ FAILED ] variable undefined!`n" + exit 1 +} + + + + +$___target = "${env:LIBS_HESTIA}\HestiaKERNEL\OS\Is_Command_Builtin.ps1" +$null = Write-Host "Checking Library file (${___target})..." +if (-not (Test-Path -Path $___target)) { + $null = Write-Host "[ FAILED ] missing file!`n" + exit 1 +} + + + + +$null = Write-Host "Import function library..." +$null = . $___target +if (-not (Get-Command 'HestiaKERNEL-Is-Command-Builtin-OS' -errorAction SilentlyContinue)) { + $null = Write-Host "[ FAILED ] error on import!`n" + exit 1 +} + + + + +$___input = "Awebaergaerrgae" +$___expect = 0 +$___output = HestiaKERNEL-Is-Command-Builtin-OS $___input +$null = Write-Host "Given input :`n|${___input}|`n" +$null = Write-Host "Given expect :`n|${___expect}|`n" +$null = Write-Host "Got Output :`n|${___output}|`n" + + + + +# assert result +if ("${___output}" -ne "${___expect}") { + $null = Write-Host "[ PASSED ]" + exit 0 +} +$null = Write-Host "[ FAILED ] unexpected/inconsistent output!" +exit 1 diff --git a/Shell/tests/OS/Is_Command_Builtin/2.sh b/Shell/tests/OS/Is_Command_Builtin/2.sh new file mode 100755 index 0000000..04e855e --- /dev/null +++ b/Shell/tests/OS/Is_Command_Builtin/2.sh @@ -0,0 +1,73 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +1>&2 printf -- "%s\n" "\ +TEST CASE : +HestiaKERNEL_Is_Command_Builtin + +DESCRIPTION: +Function can identify an invalid shell builtin. +" + + + + +1>&2 printf -- "Checking LIBS_HESTIA pathing: (%s)\n" "$LIBS_HESTIA" +if [ "$LIBS_HESTIA" = "" ]; then + 1>&2 printf -- "[ FAILED ] variable undefined!\n" + exit 1 +fi + + + + +___target="${LIBS_HESTIA}/HestiaKERNEL/OS/Is_Command_Builtin.sh" +1>&2 printf -- "Checking Library file (%s)\n" "$___target" +if [ ! -f "$___target" ]; then + 1>&2 printf -- "[ FAILED ] missing file!\n" + exit 1 +fi + + + + +1>&2 printf -- "Import function library...\n" +. "$___target" +___target="$(type HestiaKERNEL_Is_Command_Builtin_OS)" +if [ ! "${___target##*not found}" = "$___target" ]; then + 1>&2 printf -- "[ FAILED ] error on import!\n" + exit 1 +fi + + + + +___input="awebaergaerrgae" +1>&2 printf -- "Given input :\n|%s|\n\n" "$___input" + +___expect="0" +1>&2 printf -- "Given expect :\n|not %s|\n\n" "$___expect" + +___output="$(HestiaKERNEL_Is_Command_Builtin_OS "$___input")" +___process=$? +1>&2 printf -- "Given output :\n|%s|\n\n" "$___output" +1>&2 printf -- "Given exit code :\n|%s|\n\n" "$___process" + + + + +# assert result +if [ ! "$___output" = "$___expect" ]; then + 1>&2 printf -- "[ PASSED ]\n" + exit 0 +fi +1>&2 printf -- "[ FAILED ] unexpected/inconsistent output!\n" +exit 1 diff --git a/Shell/tests/OS/Is_Command_External/0.ps1 b/Shell/tests/OS/Is_Command_External/0.ps1 new file mode 100755 index 0000000..fa5c2df --- /dev/null +++ b/Shell/tests/OS/Is_Command_External/0.ps1 @@ -0,0 +1,69 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +$null = Write-Host @" +TEST CASE : +HestiaKERNEL-Is-Command-External + +DESCRIPTION: +Function can identify a proper executable. + +"@ + + + + +$null = Write-Host "Checking LIBS_HESTIA pathing: (${env:LIBS_HESTIA})" +if ("${env:LIBS_HESTIA}" -eq "") { + $null = Write-Host "[ FAILED ] variable undefined!`n" + exit 1 +} + + + + +$___target = "${env:LIBS_HESTIA}\HestiaKERNEL\OS\Is_Command_External.ps1" +$null = Write-Host "Checking Library file (${___target})..." +if (-not (Test-Path -Path $___target)) { + $null = Write-Host "[ FAILED ] missing file!`n" + exit 1 +} + + + + +$null = Write-Host "Import function library..." +$null = . $___target +if (-not (Get-Command 'HestiaKERNEL-Is-Command-External-OS' -errorAction SilentlyContinue)) { + $null = Write-Host "[ FAILED ] error on import!`n" + exit 1 +} + + + + +$___input = "notepad" +$___expect = 0 +$___output = HestiaKERNEL-Is-Command-External-OS $___input +$null = Write-Host "Given input :`n|${___input}|`n" +$null = Write-Host "Given expect :`n|${___expect}|`n" +$null = Write-Host "Got Output :`n|${___output}|`n" + + + + +# assert result +if ("${___output}" -eq "${___expect}") { + $null = Write-Host "[ PASSED ]" + exit 0 +} +$null = Write-Host "[ FAILED ] unexpected/inconsistent output!" +exit 1 diff --git a/Shell/tests/OS/Is_Command_External/0.sh b/Shell/tests/OS/Is_Command_External/0.sh new file mode 100755 index 0000000..6774b5e --- /dev/null +++ b/Shell/tests/OS/Is_Command_External/0.sh @@ -0,0 +1,73 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +1>&2 printf -- "%s\n" "\ +TEST CASE : +HestiaKERNEL_Is_Command_External + +DESCRIPTION: +Function can identify a proper executable. +" + + + + +1>&2 printf -- "Checking LIBS_HESTIA pathing: (%s)\n" "$LIBS_HESTIA" +if [ "$LIBS_HESTIA" = "" ]; then + 1>&2 printf -- "[ FAILED ] variable undefined!\n" + exit 1 +fi + + + + +___target="${LIBS_HESTIA}/HestiaKERNEL/OS/Is_Command_External.sh" +1>&2 printf -- "Checking Library file (%s)\n" "$___target" +if [ ! -f "$___target" ]; then + 1>&2 printf -- "[ FAILED ] missing file!\n" + exit 1 +fi + + + + +1>&2 printf -- "Import function library...\n" +. "$___target" +___target="$(type HestiaKERNEL_Is_Command_External_OS)" +if [ ! "${___target##*not found}" = "$___target" ]; then + 1>&2 printf -- "[ FAILED ] error on import!\n" + exit 1 +fi + + + + +___input="dd" +1>&2 printf -- "Given input :\n|%s|\n\n" "$___input" + +___expect="0" +1>&2 printf -- "Given expect :\n|%s|\n\n" "$___expect" + +___output="$(HestiaKERNEL_Is_Command_External_OS "$___input")" +___process=$? +1>&2 printf -- "Given output :\n|%s|\n\n" "$___output" +1>&2 printf -- "Given exit code :\n|%s|\n\n" "$___process" + + + + +# assert result +if [ "$___output" = "$___expect" ]; then + 1>&2 printf -- "[ PASSED ]\n" + exit 0 +fi +1>&2 printf -- "[ FAILED ] unexpected/inconsistent output!\n" +exit 1 diff --git a/Shell/tests/OS/Is_Command_External/1.ps1 b/Shell/tests/OS/Is_Command_External/1.ps1 new file mode 100755 index 0000000..3af9433 --- /dev/null +++ b/Shell/tests/OS/Is_Command_External/1.ps1 @@ -0,0 +1,69 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +$null = Write-Host @" +TEST CASE : +HestiaKERNEL-Is-Command-External + +DESCRIPTION: +Function can identify an empty executable. + +"@ + + + + +$null = Write-Host "Checking LIBS_HESTIA pathing: (${env:LIBS_HESTIA})" +if ("${env:LIBS_HESTIA}" -eq "") { + $null = Write-Host "[ FAILED ] variable undefined!`n" + exit 1 +} + + + + +$___target = "${env:LIBS_HESTIA}\HestiaKERNEL\OS\Is_Command_External.ps1" +$null = Write-Host "Checking Library file (${___target})..." +if (-not (Test-Path -Path $___target)) { + $null = Write-Host "[ FAILED ] missing file!`n" + exit 1 +} + + + + +$null = Write-Host "Import function library..." +$null = . $___target +if (-not (Get-Command 'HestiaKERNEL-Is-Command-External-OS' -errorAction SilentlyContinue)) { + $null = Write-Host "[ FAILED ] error on import!`n" + exit 1 +} + + + + +$___input = "" +$___expect = 0 +$___output = HestiaKERNEL-Is-Command-External-OS $___input +$null = Write-Host "Given input :`n|${___input}|`n" +$null = Write-Host "Given expect :`n|not ${___expect}|`n" +$null = Write-Host "Got Output :`n|${___output}|`n" + + + + +# assert result +if ("${___output}" -ne "${___expect}") { + $null = Write-Host "[ PASSED ]" + exit 0 +} +$null = Write-Host "[ FAILED ] unexpected/inconsistent output!" +exit 1 diff --git a/Shell/tests/OS/Is_Command_External/1.sh b/Shell/tests/OS/Is_Command_External/1.sh new file mode 100755 index 0000000..fc51a68 --- /dev/null +++ b/Shell/tests/OS/Is_Command_External/1.sh @@ -0,0 +1,73 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +1>&2 printf -- "%s\n" "\ +TEST CASE : +HestiaKERNEL_Is_Command_External + +DESCRIPTION: +Function can identify an empty executable. +" + + + + +1>&2 printf -- "Checking LIBS_HESTIA pathing: (%s)\n" "$LIBS_HESTIA" +if [ "$LIBS_HESTIA" = "" ]; then + 1>&2 printf -- "[ FAILED ] variable undefined!\n" + exit 1 +fi + + + + +___target="${LIBS_HESTIA}/HestiaKERNEL/OS/Is_Command_External.sh" +1>&2 printf -- "Checking Library file (%s)\n" "$___target" +if [ ! -f "$___target" ]; then + 1>&2 printf -- "[ FAILED ] missing file!\n" + exit 1 +fi + + + + +1>&2 printf -- "Import function library...\n" +. "$___target" +___target="$(type HestiaKERNEL_Is_Command_External_OS)" +if [ ! "${___target##*not found}" = "$___target" ]; then + 1>&2 printf -- "[ FAILED ] error on import!\n" + exit 1 +fi + + + + +___input="" +1>&2 printf -- "Given input :\n|%s|\n\n" "$___input" + +___expect="0" +1>&2 printf -- "Given expect :\n|not %s|\n\n" "$___expect" + +___output="$(HestiaKERNEL_Is_Command_External_OS "$___input")" +___process=$? +1>&2 printf -- "Given output :\n|%s|\n\n" "$___output" +1>&2 printf -- "Given exit code :\n|%s|\n\n" "$___process" + + + + +# assert result +if [ ! "$___output" = "$___expect" ]; then + 1>&2 printf -- "[ PASSED ]\n" + exit 0 +fi +1>&2 printf -- "[ FAILED ] unexpected/inconsistent output!\n" +exit 1 diff --git a/Shell/tests/OS/Is_Command_External/2.ps1 b/Shell/tests/OS/Is_Command_External/2.ps1 new file mode 100755 index 0000000..3c9c72d --- /dev/null +++ b/Shell/tests/OS/Is_Command_External/2.ps1 @@ -0,0 +1,69 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +$null = Write-Host @" +TEST CASE : +HestiaKERNEL-Is-Command-External + +DESCRIPTION: +Function can identify an invalid executable. + +"@ + + + + +$null = Write-Host "Checking LIBS_HESTIA pathing: (${env:LIBS_HESTIA})" +if ("${env:LIBS_HESTIA}" -eq "") { + $null = Write-Host "[ FAILED ] variable undefined!`n" + exit 1 +} + + + + +$___target = "${env:LIBS_HESTIA}\HestiaKERNEL\OS\Is_Command_External.ps1" +$null = Write-Host "Checking Library file (${___target})..." +if (-not (Test-Path -Path $___target)) { + $null = Write-Host "[ FAILED ] missing file!`n" + exit 1 +} + + + + +$null = Write-Host "Import function library..." +$null = . $___target +if (-not (Get-Command 'HestiaKERNEL-Is-Command-External-OS' -errorAction SilentlyContinue)) { + $null = Write-Host "[ FAILED ] error on import!`n" + exit 1 +} + + + + +$___input = "awrbaehejrbaeb" +$___expect = 0 +$___output = HestiaKERNEL-Is-Command-External-OS $___input +$null = Write-Host "Given input :`n|${___input}|`n" +$null = Write-Host "Given expect :`n|not ${___expect}|`n" +$null = Write-Host "Got Output :`n|${___output}|`n" + + + + +# assert result +if ("${___output}" -ne "${___expect}") { + $null = Write-Host "[ PASSED ]" + exit 0 +} +$null = Write-Host "[ FAILED ] unexpected/inconsistent output!" +exit 1 diff --git a/Shell/tests/OS/Is_Command_External/2.sh b/Shell/tests/OS/Is_Command_External/2.sh new file mode 100755 index 0000000..7bb6aa0 --- /dev/null +++ b/Shell/tests/OS/Is_Command_External/2.sh @@ -0,0 +1,73 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +1>&2 printf -- "%s\n" "\ +TEST CASE : +HestiaKERNEL_Is_Command_External + +DESCRIPTION: +Function can identify an invalid executable. +" + + + + +1>&2 printf -- "Checking LIBS_HESTIA pathing: (%s)\n" "$LIBS_HESTIA" +if [ "$LIBS_HESTIA" = "" ]; then + 1>&2 printf -- "[ FAILED ] variable undefined!\n" + exit 1 +fi + + + + +___target="${LIBS_HESTIA}/HestiaKERNEL/OS/Is_Command_External.sh" +1>&2 printf -- "Checking Library file (%s)\n" "$___target" +if [ ! -f "$___target" ]; then + 1>&2 printf -- "[ FAILED ] missing file!\n" + exit 1 +fi + + + + +1>&2 printf -- "Import function library...\n" +. "$___target" +___target="$(type HestiaKERNEL_Is_Command_External_OS)" +if [ ! "${___target##*not found}" = "$___target" ]; then + 1>&2 printf -- "[ FAILED ] error on import!\n" + exit 1 +fi + + + + +___input="awrbaehejrbaeb" +1>&2 printf -- "Given input :\n|%s|\n\n" "$___input" + +___expect="0" +1>&2 printf -- "Given expect :\n|not %s|\n\n" "$___expect" + +___output="$(HestiaKERNEL_Is_Command_External_OS "$___input")" +___process=$? +1>&2 printf -- "Given output :\n|%s|\n\n" "$___output" +1>&2 printf -- "Given exit code :\n|%s|\n\n" "$___process" + + + + +# assert result +if [ ! "$___output" = "$___expect" ]; then + 1>&2 printf -- "[ PASSED ]\n" + exit 0 +fi +1>&2 printf -- "[ FAILED ] unexpected/inconsistent output!\n" +exit 1 diff --git a/Shell/tests/OS/Is_Command_Function/0.ps1 b/Shell/tests/OS/Is_Command_Function/0.ps1 new file mode 100755 index 0000000..13d9241 --- /dev/null +++ b/Shell/tests/OS/Is_Command_Function/0.ps1 @@ -0,0 +1,69 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +$null = Write-Host @" +TEST CASE : +HestiaKERNEL-Is-Command-Function + +DESCRIPTION: +Function can identify a proper function. + +"@ + + + + +$null = Write-Host "Checking LIBS_HESTIA pathing: (${env:LIBS_HESTIA})" +if ("${env:LIBS_HESTIA}" -eq "") { + $null = Write-Host "[ FAILED ] variable undefined!`n" + exit 1 +} + + + + +$___target = "${env:LIBS_HESTIA}\HestiaKERNEL\OS\Is_Command_Function.ps1" +$null = Write-Host "Checking Library file (${___target})..." +if (-not (Test-Path -Path $___target)) { + $null = Write-Host "[ FAILED ] missing file!`n" + exit 1 +} + + + + +$null = Write-Host "Import function library..." +$null = . $___target +if (-not (Get-Command 'HestiaKERNEL-Is-Command-Function-OS' -errorAction SilentlyContinue)) { + $null = Write-Host "[ FAILED ] error on import!`n" + exit 1 +} + + + + +$___input = "HestiaKERNEL-Is-Command-Function-OS" +$___expect = 0 +$___output = HestiaKERNEL-Is-Command-Function-OS $___input +$null = Write-Host "Given input :`n|${___input}|`n" +$null = Write-Host "Given expect :`n|${___expect}|`n" +$null = Write-Host "Got Output :`n|${___output}|`n" + + + + +# assert result +if ("${___output}" -eq "${___expect}") { + $null = Write-Host "[ PASSED ]" + exit 0 +} +$null = Write-Host "[ FAILED ] unexpected/inconsistent output!" +exit 1 diff --git a/Shell/tests/OS/Is_Command_Function/0.sh b/Shell/tests/OS/Is_Command_Function/0.sh new file mode 100755 index 0000000..e1a5e46 --- /dev/null +++ b/Shell/tests/OS/Is_Command_Function/0.sh @@ -0,0 +1,73 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +1>&2 printf -- "%s\n" "\ +TEST CASE : +HestiaKERNEL_Is_Command_Function + +DESCRIPTION: +Function can identify a proper function. +" + + + + +1>&2 printf -- "Checking LIBS_HESTIA pathing: (%s)\n" "$LIBS_HESTIA" +if [ "$LIBS_HESTIA" = "" ]; then + 1>&2 printf -- "[ FAILED ] variable undefined!\n" + exit 1 +fi + + + + +___target="${LIBS_HESTIA}/HestiaKERNEL/OS/Is_Command_Function.sh" +1>&2 printf -- "Checking Library file (%s)\n" "$___target" +if [ ! -f "$___target" ]; then + 1>&2 printf -- "[ FAILED ] missing file!\n" + exit 1 +fi + + + + +1>&2 printf -- "Import function library...\n" +. "$___target" +___target="$(type HestiaKERNEL_Is_Command_Function_OS)" +if [ ! "${___target##*not found}" = "$___target" ]; then + 1>&2 printf -- "[ FAILED ] error on import!\n" + exit 1 +fi + + + + +___input="HestiaKERNEL_Is_Command_Function_OS" +1>&2 printf -- "Given input :\n|%s|\n\n" "$___input" + +___expect="0" +1>&2 printf -- "Given expect :\n|%s|\n\n" "$___expect" + +___output="$(HestiaKERNEL_Is_Command_Function_OS "$___input")" +___process=$? +1>&2 printf -- "Given output :\n|%s|\n\n" "$___output" +1>&2 printf -- "Given exit code :\n|%s|\n\n" "$___process" + + + + +# assert result +if [ "$___output" = "$___expect" ]; then + 1>&2 printf -- "[ PASSED ]\n" + exit 0 +fi +1>&2 printf -- "[ FAILED ] unexpected/inconsistent output!\n" +exit 1 diff --git a/Shell/tests/OS/Is_Command_Function/1.ps1 b/Shell/tests/OS/Is_Command_Function/1.ps1 new file mode 100755 index 0000000..13d9241 --- /dev/null +++ b/Shell/tests/OS/Is_Command_Function/1.ps1 @@ -0,0 +1,69 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +$null = Write-Host @" +TEST CASE : +HestiaKERNEL-Is-Command-Function + +DESCRIPTION: +Function can identify a proper function. + +"@ + + + + +$null = Write-Host "Checking LIBS_HESTIA pathing: (${env:LIBS_HESTIA})" +if ("${env:LIBS_HESTIA}" -eq "") { + $null = Write-Host "[ FAILED ] variable undefined!`n" + exit 1 +} + + + + +$___target = "${env:LIBS_HESTIA}\HestiaKERNEL\OS\Is_Command_Function.ps1" +$null = Write-Host "Checking Library file (${___target})..." +if (-not (Test-Path -Path $___target)) { + $null = Write-Host "[ FAILED ] missing file!`n" + exit 1 +} + + + + +$null = Write-Host "Import function library..." +$null = . $___target +if (-not (Get-Command 'HestiaKERNEL-Is-Command-Function-OS' -errorAction SilentlyContinue)) { + $null = Write-Host "[ FAILED ] error on import!`n" + exit 1 +} + + + + +$___input = "HestiaKERNEL-Is-Command-Function-OS" +$___expect = 0 +$___output = HestiaKERNEL-Is-Command-Function-OS $___input +$null = Write-Host "Given input :`n|${___input}|`n" +$null = Write-Host "Given expect :`n|${___expect}|`n" +$null = Write-Host "Got Output :`n|${___output}|`n" + + + + +# assert result +if ("${___output}" -eq "${___expect}") { + $null = Write-Host "[ PASSED ]" + exit 0 +} +$null = Write-Host "[ FAILED ] unexpected/inconsistent output!" +exit 1 diff --git a/Shell/tests/OS/Is_Command_Function/1.sh b/Shell/tests/OS/Is_Command_Function/1.sh new file mode 100755 index 0000000..eece763 --- /dev/null +++ b/Shell/tests/OS/Is_Command_Function/1.sh @@ -0,0 +1,73 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +1>&2 printf -- "%s\n" "\ +TEST CASE : +HestiaKERNEL_Is_Command_Function + +DESCRIPTION: +Function can identify a empty function. +" + + + + +1>&2 printf -- "Checking LIBS_HESTIA pathing: (%s)\n" "$LIBS_HESTIA" +if [ "$LIBS_HESTIA" = "" ]; then + 1>&2 printf -- "[ FAILED ] variable undefined!\n" + exit 1 +fi + + + + +___target="${LIBS_HESTIA}/HestiaKERNEL/OS/Is_Command_Function.sh" +1>&2 printf -- "Checking Library file (%s)\n" "$___target" +if [ ! -f "$___target" ]; then + 1>&2 printf -- "[ FAILED ] missing file!\n" + exit 1 +fi + + + + +1>&2 printf -- "Import function library...\n" +. "$___target" +___target="$(type HestiaKERNEL_Is_Command_Function_OS)" +if [ ! "${___target##*not found}" = "$___target" ]; then + 1>&2 printf -- "[ FAILED ] error on import!\n" + exit 1 +fi + + + + +___input="" +1>&2 printf -- "Given input :\n|%s|\n\n" "$___input" + +___expect="0" +1>&2 printf -- "Given expect :\n|not %s|\n\n" "$___expect" + +___output="$(HestiaKERNEL_Is_Command_Function_OS "$___input")" +___process=$? +1>&2 printf -- "Given output :\n|%s|\n\n" "$___output" +1>&2 printf -- "Given exit code :\n|%s|\n\n" "$___process" + + + + +# assert result +if [ ! "$___output" = "$___expect" ]; then + 1>&2 printf -- "[ PASSED ]\n" + exit 0 +fi +1>&2 printf -- "[ FAILED ] unexpected/inconsistent output!\n" +exit 1 diff --git a/Shell/tests/OS/Is_Command_Function/2.ps1 b/Shell/tests/OS/Is_Command_Function/2.ps1 new file mode 100755 index 0000000..cd7a22b --- /dev/null +++ b/Shell/tests/OS/Is_Command_Function/2.ps1 @@ -0,0 +1,69 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +$null = Write-Host @" +TEST CASE : +HestiaKERNEL-Is-Command-Function + +DESCRIPTION: +Function can identify an invalid function. + +"@ + + + + +$null = Write-Host "Checking LIBS_HESTIA pathing: (${env:LIBS_HESTIA})" +if ("${env:LIBS_HESTIA}" -eq "") { + $null = Write-Host "[ FAILED ] variable undefined!`n" + exit 1 +} + + + + +$___target = "${env:LIBS_HESTIA}\HestiaKERNEL\OS\Is_Command_Function.ps1" +$null = Write-Host "Checking Library file (${___target})..." +if (-not (Test-Path -Path $___target)) { + $null = Write-Host "[ FAILED ] missing file!`n" + exit 1 +} + + + + +$null = Write-Host "Import function library..." +$null = . $___target +if (-not (Get-Command 'HestiaKERNEL-Is-Command-Function-OS' -errorAction SilentlyContinue)) { + $null = Write-Host "[ FAILED ] error on import!`n" + exit 1 +} + + + + +$___input = "aebeargaergeag" +$___expect = 0 +$___output = HestiaKERNEL-Is-Command-Function-OS $___input +$null = Write-Host "Given input :`n|${___input}|`n" +$null = Write-Host "Given expect :`n|${___expect}|`n" +$null = Write-Host "Got Output :`n|${___output}|`n" + + + + +# assert result +if ("${___output}" -eq "${___expect}") { + $null = Write-Host "[ PASSED ]" + exit 0 +} +$null = Write-Host "[ FAILED ] unexpected/inconsistent output!" +exit 1 diff --git a/Shell/tests/OS/Is_Command_Function/2.sh b/Shell/tests/OS/Is_Command_Function/2.sh new file mode 100755 index 0000000..1744b8d --- /dev/null +++ b/Shell/tests/OS/Is_Command_Function/2.sh @@ -0,0 +1,73 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +1>&2 printf -- "%s\n" "\ +TEST CASE : +HestiaKERNEL_Is_Command_Function + +DESCRIPTION: +Function can identify an invalid function. +" + + + + +1>&2 printf -- "Checking LIBS_HESTIA pathing: (%s)\n" "$LIBS_HESTIA" +if [ "$LIBS_HESTIA" = "" ]; then + 1>&2 printf -- "[ FAILED ] variable undefined!\n" + exit 1 +fi + + + + +___target="${LIBS_HESTIA}/HestiaKERNEL/OS/Is_Command_Function.sh" +1>&2 printf -- "Checking Library file (%s)\n" "$___target" +if [ ! -f "$___target" ]; then + 1>&2 printf -- "[ FAILED ] missing file!\n" + exit 1 +fi + + + + +1>&2 printf -- "Import function library...\n" +. "$___target" +___target="$(type HestiaKERNEL_Is_Command_Function_OS)" +if [ ! "${___target##*not found}" = "$___target" ]; then + 1>&2 printf -- "[ FAILED ] error on import!\n" + exit 1 +fi + + + + +___input="aebeargaergeag" +1>&2 printf -- "Given input :\n|%s|\n\n" "$___input" + +___expect="0" +1>&2 printf -- "Given expect :\n|not %s|\n\n" "$___expect" + +___output="$(HestiaKERNEL_Is_Command_Function_OS "$___input")" +___process=$? +1>&2 printf -- "Given output :\n|%s|\n\n" "$___output" +1>&2 printf -- "Given exit code :\n|%s|\n\n" "$___process" + + + + +# assert result +if [ ! "$___output" = "$___expect" ]; then + 1>&2 printf -- "[ PASSED ]\n" + exit 0 +fi +1>&2 printf -- "[ FAILED ] unexpected/inconsistent output!\n" +exit 1