-
Notifications
You must be signed in to change notification settings - Fork 5
/
runexamples.sh
executable file
·92 lines (71 loc) · 2.85 KB
/
runexamples.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/usr/bin/env bash
#--------------------------------------------------------------------------------------
# Run the examples in the examples sub-directory and report if there is an error
#--------------------------------------------------------------------------------------
THIS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source ${THIS_DIR}/examples/local.sh
VERBOSE="No"
#--------------------------------------------------------------------------------------
# Run a clingo program. Note: Clingo seems to return a return code of either 30
# or 10 (rather than 0) even though it appears to finish without an error. I'm
# not sure why.
# --------------------------------------------------------------------------------------
run_clingo(){
local asp=$1
local dir=$( dirname $asp )
local base=$( basename $asp )
echo "======================================================================="
echo "Running clingo program: {$asp}"
result=$( cd $dir ; clingo $base )
status=$?
if [ "$status" != "30" ] && [ "$status" != "10" ] ; then
echo ""
echo "Error $status running: {$asp}"
echo ""
echo "$result"
echo "======================================================================="
return 1
fi
if [ "$VERBOSE" == "Yes" ] ; then
echo "$result"
fi
echo "======================================================================="
return 0
}
#--------------------------------------------------------------------------------------
# Run a python
#--------------------------------------------------------------------------------------
run_python(){
local prg=$1
local dir=$( dirname $prg )
local base=$( basename $prg )
echo "======================================================================="
echo "Running Python clingo program: {$prg}"
result=$( cd $dir ; python $base )
status=$?
if [ "$status" != "0" ] ; then
echo ""
echo "Error $status running: {$prg}"
echo ""
echo "$result"
echo "======================================================================="
return 1
fi
if [ "$VERBOSE" == "Yes" ] ; then
echo "$result"
fi
echo "======================================================================="
return 0
}
#--------------------------------------------------------------------------------------
#
#--------------------------------------------------------------------------------------
run_clingo examples/debugging/simple_predicate.lp
run_clingo examples/grounding_context/embedded_grounding_context.lp
run_python examples/introspection/introspection.py
run_python examples/monkey_patching/quickstart.py
run_clingo examples/quickstart/embedded_quickstart.lp
run_python examples/quickstart/quickstart.py
run_clingo examples/combine_fields/combine_fields.lp
run_clingo examples/nested_list/nested_list.lp
run_clingo examples/join_with_ampersand/join_with_ampersand.lp