-
Notifications
You must be signed in to change notification settings - Fork 318
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add (user mode testing): add a beginning of a simple bash unit tester…
… for the shell_commands script and it's functions
- Loading branch information
Showing
2 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
cime_config/testdefs/testmods_dirs/clm/FatesSetupParamBuild/README.md
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,7 @@ | ||
|
||
User mod directory to make sure the user is setup to run the FATES modify param file script. | ||
IF not it trys some different options and prints messages regarding what worked, and what the user | ||
needs to do if nothing worked. | ||
|
||
|
||
|
37 changes: 37 additions & 0 deletions
37
cime_config/testdefs/testmods_dirs/clm/FatesSetupParamBuild/run_shell_commands_tests
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,37 @@ | ||
#!/bin/bash | ||
|
||
# Define a custom error handler function | ||
handle_error() { | ||
echo "An error occurred: $1" | ||
echo "error code: $?" | ||
# Additional error handling code can go here | ||
return 1 | ||
} | ||
|
||
# Set the error handler to be called when an error occurs | ||
trap 'handle_error "Something went wrong!"' ERR | ||
|
||
host=`hostname -f` | ||
if [[ "$host" =~ derecho*.hpc.ucar.edu || "$host" =~ d*.hpc.ucar.edu ]] ; then | ||
echo "Running on Derecho..." >&2 | ||
echo ".... making sure conda is loaded..." >&2 | ||
module load conda | ||
else | ||
echo "Not a recognized host: $host" >&2 | ||
exit 5 | ||
fi | ||
echo "Test if shell_commands will run..." | ||
. ./shell_commands > /dev/null | ||
|
||
echo "Now do some tests of the bash subroutines" >&2 | ||
unset DEBUG | ||
$(log_msg_if_debug "Die with Error since DEBUG is unset") | ||
if [[ "$?" -eq "0" ]]; then | ||
echo "Should have died with an error..." >&2 | ||
exit 1 | ||
fi | ||
echo "after DEBUG test" | ||
DEBUG=0 | ||
$(log_msg_if_debug "Die with Error since too many options are input" "another option") | ||
|
||
echo "Successful" |