comparison test/build-bc-overload-tests.sh @ 20340:4f911b4e012b

allow bc-overload tests to be written to an arbitrary directory * build-bc-overload-tests.sh: Fix file name in comments to match file name. Accept second argument to specify directory in which to write output files. * test/Makefile.am (bc-overload-tests.stamp): Adapt rule.
author John W. Eaton <jwe@octave.org>
date Thu, 02 Jul 2015 18:07:24 -0400
parents 4197fc428c7d
children bacaec9b5535
comparison
equal deleted inserted replaced
20339:dadfb0be8a42 20340:4f911b4e012b
55 --list-classes) 55 --list-classes)
56 echo $CLASSES 56 echo $CLASSES
57 exit 57 exit
58 ;; 58 ;;
59 *) 59 *)
60 expected_results_file="$1" 60 echo "usage: build-bc-overload-tests.sh option" 1>&2
61 exit 1
61 ;; 62 ;;
62 esac 63 esac
64 elif [ $# -eq 2 ]; then
65 output_dir="$1"
66 expected_results_file="$2"
63 else 67 else
64 echo "usage: build_bc_overload_tests.sh expected-results-file" 1>&2 68 echo "usage: build-bc-overload-tests.sh expected-results-file" 1>&2
65 exit 1 69 exit 1
66 fi 70 fi
67 71
68 for class in $CLASSES; do 72 for class in $CLASSES; do
69 DIR="@$class" 73 DIR="$output_dir/@$class"
70 test -d $DIR || mkdir $DIR || { echo "error: could not create $DIR"; exit; } 74 test -d $DIR || mkdir $DIR || { echo "error: could not create $DIR"; exit; }
71 cat > $DIR/tbcover.m << EOF 75 cat > $DIR/tbcover.m << EOF
72 % !!! DO NOT EDIT !!! 76 % !!! DO NOT EDIT !!!
73 % generated automatically by build_bc_overload_tests.sh 77 % generated automatically by build-bc-overload-tests.sh
74 function s = tbcover (x, y) 78 function s = tbcover (x, y)
75 s = '$class'; 79 s = '$class';
76 EOF 80 EOF
77 done 81 done
78 82
79 cat > tbcover.m << EOF 83 cat > $output_dir/tbcover.m << EOF
80 % !!! DO NOT EDIT !!! 84 % !!! DO NOT EDIT !!!
81 % generated automatically by build_bc_overload_tests.sh 85 % generated automatically by build-bc-overload-tests.sh
82 function s = tbcover (x, y) 86 function s = tbcover (x, y)
83 s = 'none'; 87 s = 'none';
84 EOF 88 EOF
85 89
86 if test "$1" = "overloads_only" ; then 90 if test "$1" = "overloads_only" ; then
87 exit 91 exit
88 fi 92 fi
89 93
90 cat > bc-overloads.tst << EOF 94 cat > $output_dir/bc-overloads.tst << EOF
91 ## !!! DO NOT EDIT !!! 95 ## !!! DO NOT EDIT !!!
92 ## THIS IS AN AUTOMATICALLY GENERATED FILE 96 ## THIS IS AN AUTOMATICALLY GENERATED FILE
93 ## modify build_bc_overload_tests.sh to generate the tests you need. 97 ## modify build-bc-overload-tests.sh to generate the tests you need.
94 98
95 %!shared ex 99 %!shared ex
96 %! ex.double = 1; 100 %! ex.double = 1;
97 %! ex.single = single (1); 101 %! ex.single = single (1);
98 %! ex.logical = true; 102 %! ex.logical = true;
111 115
112 EOF 116 EOF
113 117
114 cat $expected_results_file | \ 118 cat $expected_results_file | \
115 while read cl1 cl2 clr ; do 119 while read cl1 cl2 clr ; do
116 cat >> bc-overloads.tst << EOF 120 cat >> $output_dir/bc-overloads.tst << EOF
117 %% Name call 121 %% Name call
118 %!assert (tbcover (ex.$cl1, ex.$cl2), "$clr") 122 %!assert (tbcover (ex.$cl1, ex.$cl2), "$clr")
119 %% Handle call 123 %% Handle call
120 %!assert ((@tbcover) (ex.$cl1, ex.$cl2), "$clr") 124 %!assert ((@tbcover) (ex.$cl1, ex.$cl2), "$clr")
121 125
122 EOF 126 EOF
123 done 127 done
124 128
125 cat >> bc-overloads.tst << EOF 129 cat >> $output_dir/bc-overloads.tst << EOF
126 %%test handles through cellfun 130 %%test handles through cellfun
127 %!test 131 %!test
128 %! f = fieldnames (ex); 132 %! f = fieldnames (ex);
129 %! n = numel (f); 133 %! n = numel (f);
130 %! s = c1 = c2 = cell (n); 134 %! s = c1 = c2 = cell (n);