-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathtest.bash
executable file
·57 lines (48 loc) · 1.56 KB
/
test.bash
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
56
57
#!/bin/bash
export PATH=$PATH:.
logC () { [[ $# == 2 ]] && tput setaf $2 || tput setaf 3; echo -e "$1"; tput setaf 15; }
logExit () {
[[ $1 == '0' ]] && tput setaf 2 || tput setaf 1;
[[ $1 == '0' ]] && echo -e "$2 PASSED" || echo -e "$2 FAILED";
tput setaf 15;
[[ $1 == '0' ]] || exit -1
}
HELLO="examples/hello.m"
HELLOOUT="hello world"
ARGS="examples/print-args.m"
WEIRD="examples/script with weird name.m"
WEIRDOUT="Wow you ran me even if I have spaces in name!"
EXISTS="examples/when-file-already-exists.m"
EXISTSOUT="objc-run: file already exists at /when-file-already-exists ... exiting"
PODTEST1="examples/MACollectionUtilitiesTest.m"
PODTEST2="examples/CocoaPodsTest.m"
logC "Testing output of $HELLO is $HELLOOUT"
diff <( objc-run $HELLO ) - << EOF
$HELLOOUT
EOF
logExit $? $HELLO
logC "Testing output of $ARGS"
diff <( objc-run $ARGS "quoted param" ) - << EOF
argv[0]: examples/print-args
argv[1]: quoted param
EOF
logExit $? $ARGS
logC "Testing output of $WEIRD is $WEIRDOUT"
diff <( objc-run "$WEIRD" ) - << EOF
$WEIRDOUT
EOF
logExit $? $WEIRD
logC "Testing behavior when file exists with $EXISTS"
diff <( objc-run $EXISTS 2>&1 ) - << EOF
$EXISTSOUT
EOF
logExit $? $EXISTS
if which pod >/dev/null; then
logC "Running CocoaPods Test .. $PODTEST1 (with xcodebuild output supressed)"
objc-run $PODTEST1 > /dev/null
logExit $? $PODTEST1
logC "Running CocoaPods Test 2 ... $PODTEST2 (with xcodebuild output supressed)"
objc-run $PODTEST2 -quit > /dev/null
logExit $? $PODTEST2
fi
logC "All tests passed! Done." 6