-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathncoTests.sh
executable file
·57 lines (47 loc) · 1.24 KB
/
ncoTests.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash
whsPath=`grep "wrfHydroScripts" ~/.wrfHydroScripts | cut -d '=' -f2 | tr -d ' '`
source $whsPath/helpers.sh
ncosPath=`grep "ncoScripts" ~/.wrfHydroScripts | cut -d '=' -f2 | tr -d ' '`
source $ncosPath/ncFilters.sh
function testFailed {
testStr=''
if [ ! -z $1 ]; then testStr=": $1"; fi
echo -e "\e[31mTest failed${testStr}.\e[0m"
}
## UNARY TESTS
function testNaOutput {
## Arguments:
## 1: the file to check
if [ -z $1 ]
then
echo -e "\e[31mtestNaOutput requires one argument: the file to test\e[0m"
return 1
fi
f1=`getAbsPath $1`
checkExist $f1 || return 1
echo -e "\e[34mncVarNa $f1\e[0m"
result=`ncVarNa $f1`
resultRet=$?
echo "$result"
return $resultRet
}
## BINARY TESTS
function testDiffOutput {
## Arguments 1-2?
## 1: path/file.nc
## 1: path/file.nc
if [[ -z $1 ]] | [[ -z $2 ]]
then
echo -e "\e[31mTwo files required by testDiffOutput in nocTests.sh\e[0m"
return 1
fi
f1=`getAbsPath $1`
f2=`getAbsPath $2`
checkExist $f1 || return 1
checkExist $f2 || return 1
echo -e "\e[34mncVarDiff $f1 $f2\e[0m"
diffOut=`ncVarDiff $f1 $f2 2>&1`
diffRet=$?
echo "$diffOut"
return $diffRet
}