-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Shell: upgraded test libraries into HestiaKERNEL
Since the test framework is reusable, it's best to upgrade the existing ones into HestiaKERNEL library instead. Hence, let's do this. This patch upgrades test libraries into HestiaKERNEL in Shell/ directory. Co-authored-by: Shuralyov, Jean <[email protected]> Co-authored-by: Galyna, Cory <[email protected]> Co-authored-by: (Holloway) Chew, Kean Ho <[email protected]> Signed-off-by: (Holloway) Chew, Kean Ho <[email protected]>
- Loading branch information
1 parent
63e63d0
commit 0c8fbd8
Showing
61 changed files
with
3,252 additions
and
263 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# Copyright 2024 (Holloway) Chew, Kean Ho <[email protected]> | ||
# | ||
# | ||
# 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" | ||
. "${env:LIBS_HESTIA}\HestiaKERNEL\FS\Is_Directory.ps1" | ||
. "${env:LIBS_HESTIA}\HestiaKERNEL\FS\Is_File.ps1" | ||
|
||
|
||
|
||
|
||
function HestiaKERNEL-Get-Files { | ||
param ( | ||
[string]$___directory, | ||
[string]$___filter, | ||
[int]$___recursive | ||
) | ||
|
||
|
||
# validate input | ||
if ($(HestiaKERNEL-Is-Directory-FS $___directory) -ne ${env:HestiaKERNEL_ERROR_OK}) { | ||
return [string[]]@() | ||
} | ||
|
||
|
||
# execute | ||
[System.Collections.Generic.List[string]]$___list = @() | ||
foreach ($____item in (Get-ChildItem $___directory)) { | ||
if ($(HestiaKERNEL-Is-Directory-FS $____item) -eq ${env:HestiaKERNEL_ERROR_OK}) { | ||
if ($___recursive -eq 0) { | ||
continue | ||
} elseif ($___recursive -gt 0) { | ||
$___results = HestiaKERNEL-Get-Files $____item.FullName ` | ||
$___filter ` | ||
($___recursive - 1) | ||
} else { | ||
$___results = HestiaKERNEL-Get-Files $____item.FullName ` | ||
$___filter ` | ||
-1 | ||
} | ||
|
||
foreach ($___result in $___results) { | ||
$___list.Add($___result) | ||
} | ||
} elseif ($(HestiaKERNEL-Is-File-FS $____item) -eq ${env:HestiaKERNEL_ERROR_OK}) { | ||
if ($____item.Name -like "*${___filter}*") { | ||
$___list.Add($____item.FullName) | ||
} | ||
} | ||
} | ||
|
||
|
||
# report status | ||
return [string[]]$___list | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#!/bin/sh | ||
# Copyright 2024 (Holloway) Chew, Kean Ho <[email protected]> | ||
# | ||
# | ||
# 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/FS/Is_Directory.sh" | ||
. "${LIBS_HESTIA}/HestiaKERNEL/FS/Is_File.sh" | ||
. "${LIBS_HESTIA}/HestiaKERNEL/Number/Is_Number.sh" | ||
|
||
|
||
|
||
|
||
HestiaKERNEL_Get_Files_FS() { | ||
#___directory="$1" | ||
#___filter="$2" | ||
#___recursive="$3" | ||
|
||
|
||
# validate input | ||
if [ $(HestiaKERNEL_Is_Directory_FS "$1") -ne $HestiaKERNEL_ERROR_OK ]; then | ||
printf -- "" | ||
return $HestiaKERNEL_ERROR_ENTITY_INVALID | ||
fi | ||
|
||
|
||
# execute | ||
for ____item in "$1"/*; do | ||
if [ $(HestiaKERNEL_Is_Directory_FS "$____item") -eq $HestiaKERNEL_ERROR_OK ]; then | ||
if [ $(HestiaKERNEL_Is_Number "$3") -ne $HestiaKERNEL_ERROR_OK ]; then | ||
continue | ||
fi | ||
|
||
if [ $3 -eq 0 ]; then | ||
continue | ||
elif [ $3 -gt 0 ]; then | ||
HestiaKERNEL_Get_Files_FS "$____item" "$2" "$(($3 - 1))" | ||
else | ||
HestiaKERNEL_Get_Files_FS "$____item" "$2" "$3" | ||
fi | ||
elif [ $(HestiaKERNEL_Is_File_FS "$____item") -eq $HestiaKERNEL_ERROR_OK ]; then | ||
____filename="${____item##*/}" | ||
|
||
if [ "$2" = "" ]; then | ||
printf -- "%s\n" "$____item" | ||
elif [ ! "${____filename##*"$2"}" = "$____filename" ]; then | ||
printf -- "%s\n" "$____item" | ||
fi | ||
fi | ||
done | ||
|
||
|
||
# report status | ||
return $HestiaKERNEL_ERROR_OK | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Copyright 2024 (Holloway) Chew, Kean Ho <[email protected]> | ||
# | ||
# | ||
# 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.sh" | ||
|
||
|
||
|
||
|
||
function HestiaKERNEL-Is-Directory-FS { | ||
param ( | ||
[string]$___target | ||
) | ||
|
||
|
||
# validate input | ||
if ($___target -eq "") { | ||
return ${env:hestiaKERNEL_ERROR_DATA_EMPTY} | ||
} | ||
|
||
|
||
# execute | ||
if (Test-Path -PathType Container -Path $___target -ErrorAction SilentlyContinue) { | ||
return ${env:hestiaKERNEL_ERROR_OK} | ||
} | ||
|
||
|
||
# report status | ||
return ${env:hestiaKERNEL_ERROR_DATA_BAD} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/bin/sh | ||
# Copyright 2024 (Holloway) Chew, Kean Ho <[email protected]> | ||
# | ||
# | ||
# 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_Directory_FS() { | ||
#___target="$1" | ||
|
||
|
||
# validate input | ||
if [ "$1" = "" ]; then | ||
printf -- "%d" "$HestiaKERNEL_ERROR_DATA_EMPTY" | ||
return $HestiaKERNEL_ERROR_DATA_EMPTY | ||
fi | ||
|
||
|
||
# execute | ||
if [ -d "$1" ]; then | ||
printf -- "%d" "$HestiaKERNEL_ERROR_OK" | ||
return $HestiaKERNEL_ERROR_OK | ||
fi | ||
|
||
|
||
# report status | ||
printf -- "%d" "$HestiaKERNEL_ERROR_DATA_BAD" | ||
return $HestiaKERNEL_ERROR_DATA_BAD | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Copyright 2024 (Holloway) Chew, Kean Ho <[email protected]> | ||
# | ||
# | ||
# 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.sh" | ||
|
||
|
||
|
||
|
||
function HestiaKERNEL-Is-File-FS { | ||
param ( | ||
[string]$___target | ||
) | ||
|
||
|
||
# validate input | ||
if ($___target -eq "") { | ||
return ${env:hestiaKERNEL_ERROR_DATA_EMPTY} | ||
} | ||
|
||
|
||
# execute | ||
if (Test-Path -PathType leaf -Path $___target -ErrorAction SilentlyContinue) { | ||
return ${env:hestiaKERNEL_ERROR_OK} | ||
} | ||
|
||
|
||
# report status | ||
return ${env:hestiaKERNEL_ERROR_DATA_BAD} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/bin/sh | ||
# Copyright 2024 (Holloway) Chew, Kean Ho <[email protected]> | ||
# | ||
# | ||
# 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_File_FS() { | ||
#___target="$1" | ||
|
||
|
||
# validate input | ||
if [ "$1" = "" ]; then | ||
printf -- "%d" "$HestiaKERNEL_ERROR_DATA_EMPTY" | ||
return $HestiaKERNEL_ERROR_DATA_EMPTY | ||
fi | ||
|
||
|
||
# execute | ||
if [ -f "$1" ]; then | ||
printf -- "%d" "$HestiaKERNEL_ERROR_OK" | ||
return $HestiaKERNEL_ERROR_OK | ||
fi | ||
|
||
|
||
# report status | ||
printf -- "%d" "$HestiaKERNEL_ERROR_DATA_BAD" | ||
return $HestiaKERNEL_ERROR_DATA_BAD | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Copyright 2024 (Holloway) Chew, Kean Ho <[email protected]> | ||
# | ||
# | ||
# 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. | ||
|
||
|
||
|
||
|
||
# faciliate test framework | ||
${env:HestiaKERNEL_TEST_PASSED} = 0 | ||
${env:HestiaKERNEL_TEST_FAILED} = 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/sh | ||
# Copyright 2024 (Holloway) Chew, Kean Ho <[email protected]> | ||
# | ||
# | ||
# 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. | ||
|
||
|
||
|
||
|
||
# faciliate test framework | ||
export HestiaKERNEL_TEST_PASSED=0 | ||
export HestiaKERNEL_TEST_FAILED=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Copyright 2024 (Holloway) Chew, Kean Ho <[email protected]> | ||
# | ||
# | ||
# 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\Test\Codes.sh" | ||
|
||
|
||
|
||
|
||
function HestiaKERNEL-Exec-Test-Case { | ||
param ( | ||
[string]$___filepath, | ||
[string]$___report_only_failed | ||
) | ||
|
||
|
||
# validate input | ||
if ($___filepath -eq "") { | ||
return ${env:HestiaKERNEL_TEST_FAILED} | ||
} | ||
|
||
if (-not (Test-Path -Path $___filepath -PathType Leaf)) { | ||
return ${env:HestiaKERNEL_TEST_FAILED} | ||
} | ||
|
||
|
||
# execute | ||
$___process = & { | ||
$___output = . $___script 2>&1 | ||
if ($LASTEXITCODE -eq ${env:HestiaKERNEL_TEST_PASSED}) { | ||
if ($___report_only_failed -eq "") { | ||
$null = Write-Host "${___output}" | ||
} | ||
|
||
return ${env:HestiaKERNEL_TEST_PASSED} | ||
} | ||
|
||
$null = Write-Host "${___output}" | ||
return ${env:HestiaKERNEL_TEST_FAILED} | ||
} | ||
|
||
if ($___process -eq ${env:HestiaKERNEL_TEST_PASSED}) { | ||
return ${env:HestiaKERNEL_TEST_PASSED} | ||
} | ||
|
||
|
||
# report status | ||
return ${env:HestiaKERNEL_TEST_FAILED} | ||
} |
Oops, something went wrong.