-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathtestc
More file actions
executable file
·123 lines (108 loc) · 5.02 KB
/
testc
File metadata and controls
executable file
·123 lines (108 loc) · 5.02 KB
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#!/bin/sh
set -eu
tmp_dir=$(mktemp -d -t bosatsuc-XXXXXXXXXX)
cleanup() {
rm -rf "$tmp_dir"
}
trap cleanup EXIT
check_ls_output() {
output="$1"
printf '%s\n' "$output" | grep -Eq '^listing \.$'
printf '%s\n' "$output" | grep -Eq '^\[(file|dir|symlink|other|missing)\] '
printf '%s\n' "$output" | grep -Eq 'test_workspace'
summary_line=$(printf '%s\n' "$output" | sed -n 's/^listed \([0-9][0-9]*\) entries in \([0-9][0-9]*\) ns$/\1 \2/p')
[ -n "$summary_line" ]
reported_count=${summary_line%% *}
listed_count=$(printf '%s\n' "$output" | grep -Ec '^\[(file|dir|symlink|other|missing)\] ')
[ "$reported_count" -eq "$listed_count" ]
}
check_create_mode_output() {
output="$1"
printf '%s\n' "$output" | grep -Eq '^create_mode_test:ok$'
}
./bosatsuj tool transpile \
--input test_workspace/Issue1633.bosatsu \
c --test --filter Issue1633 --outdir "$tmp_dir"
cp c_runtime/*.h "$tmp_dir"/
cp c_runtime/bosatsu_runtime.c "$tmp_dir"/
cp c_runtime/bosatsu_ext_Bosatsu_l_Predef.c "$tmp_dir"/
cp c_runtime/bosatsu_ext_Bosatsu_l_Prog.c "$tmp_dir"/
cp c_runtime/bosatsu_ext_Bosatsu_l_IO_l_Core.c "$tmp_dir"/
cp c_runtime/bosatsu_ext_Bosatsu_l_IO_l_Bytes.c "$tmp_dir"/
cp c_runtime/bosatsu_ext_Bosatsu_l_Collection_l_Array.c "$tmp_dir"/
cp c_runtime/bosatsu_ext_Bosatsu_l_Num_l_Float64.c "$tmp_dir"/
GC_CFLAGS="$(pkg-config --cflags bdw-gc 2>/dev/null || true)"
GC_LIBS="$(pkg-config --libs bdw-gc 2>/dev/null || true)"
if [ -z "$GC_CFLAGS$GC_LIBS" ]; then
if [ -f /opt/homebrew/opt/bdw-gc/include/gc.h ]; then
GC_CFLAGS="-I/opt/homebrew/opt/bdw-gc/include"
GC_LIBS="-L/opt/homebrew/opt/bdw-gc/lib -lgc"
elif [ -f /usr/local/opt/bdw-gc/include/gc.h ]; then
GC_CFLAGS="-I/usr/local/opt/bdw-gc/include"
GC_LIBS="-L/usr/local/opt/bdw-gc/lib -lgc"
else
GC_LIBS="-lgc"
fi
fi
cc $GC_CFLAGS -O2 -Wall -c "$tmp_dir/bosatsu_runtime.c" -o "$tmp_dir/bosatsu_runtime.o"
cc $GC_CFLAGS -O2 -Wall -c "$tmp_dir/bosatsu_ext_Bosatsu_l_Predef.c" -o "$tmp_dir/bosatsu_ext_Bosatsu_l_Predef.o"
cc $GC_CFLAGS -O2 -Wall -c "$tmp_dir/bosatsu_ext_Bosatsu_l_Prog.c" -o "$tmp_dir/bosatsu_ext_Bosatsu_l_Prog.o"
cc $GC_CFLAGS -O2 -Wall -c "$tmp_dir/bosatsu_ext_Bosatsu_l_IO_l_Core.c" -o "$tmp_dir/bosatsu_ext_Bosatsu_l_IO_l_Core.o"
cc $GC_CFLAGS -O2 -Wall -c "$tmp_dir/bosatsu_ext_Bosatsu_l_IO_l_Bytes.c" -o "$tmp_dir/bosatsu_ext_Bosatsu_l_IO_l_Bytes.o"
cc $GC_CFLAGS -O2 -Wall -c "$tmp_dir/bosatsu_ext_Bosatsu_l_Collection_l_Array.c" -o "$tmp_dir/bosatsu_ext_Bosatsu_l_Collection_l_Array.o"
cc $GC_CFLAGS -O2 -Wall -c "$tmp_dir/bosatsu_ext_Bosatsu_l_Num_l_Float64.c" -o "$tmp_dir/bosatsu_ext_Bosatsu_l_Num_l_Float64.o"
cc $GC_CFLAGS -O2 -Wall -c "$tmp_dir/output.c" -o "$tmp_dir/output.o"
cc $GC_CFLAGS -O2 -Wall -o "$tmp_dir/test_exe" \
"$tmp_dir/output.o" \
"$tmp_dir/bosatsu_runtime.o" \
"$tmp_dir/bosatsu_ext_Bosatsu_l_Predef.o" \
"$tmp_dir/bosatsu_ext_Bosatsu_l_Prog.o" \
"$tmp_dir/bosatsu_ext_Bosatsu_l_IO_l_Core.o" \
"$tmp_dir/bosatsu_ext_Bosatsu_l_IO_l_Bytes.o" \
"$tmp_dir/bosatsu_ext_Bosatsu_l_Collection_l_Array.o" \
"$tmp_dir/bosatsu_ext_Bosatsu_l_Num_l_Float64.o" \
$GC_LIBS -lm
"$tmp_dir/test_exe"
./bosatsuj tool transpile \
--input_dir test_workspace \
--input test_workspace/Bosatsu/IO/Error.bosatsu \
--input test_workspace/Bosatsu/Collection/Array.bosatsu \
--input test_workspace/Bosatsu/IO/Core.bosatsu \
--input test_workspace/Bosatsu/IO/Bytes.bosatsu \
--input test_workspace/Bosatsu/IO/Std.bosatsu \
c --main Bosatsu/LsExample --outdir "$tmp_dir"
cc $GC_CFLAGS -O2 -Wall -c "$tmp_dir/output.c" -o "$tmp_dir/ls_output.o"
cc $GC_CFLAGS -O2 -Wall -o "$tmp_dir/ls_exe" \
"$tmp_dir/ls_output.o" \
"$tmp_dir/bosatsu_runtime.o" \
"$tmp_dir/bosatsu_ext_Bosatsu_l_Predef.o" \
"$tmp_dir/bosatsu_ext_Bosatsu_l_Prog.o" \
"$tmp_dir/bosatsu_ext_Bosatsu_l_IO_l_Core.o" \
"$tmp_dir/bosatsu_ext_Bosatsu_l_IO_l_Bytes.o" \
"$tmp_dir/bosatsu_ext_Bosatsu_l_Collection_l_Array.o" \
"$tmp_dir/bosatsu_ext_Bosatsu_l_Num_l_Float64.o" \
$GC_LIBS -lm
ls_output=$("$tmp_dir/ls_exe")
check_ls_output "$ls_output"
./bosatsuj tool transpile \
--input_dir test_workspace \
--input test_workspace/Bosatsu/IO/Error.bosatsu \
--input test_workspace/Bosatsu/Collection/Array.bosatsu \
--input test_workspace/Bosatsu/IO/Core.bosatsu \
--input test_workspace/Bosatsu/IO/Bytes.bosatsu \
--input test_workspace/Bosatsu/IO/Std.bosatsu \
--input test_workspace/Bosatsu/IO/CreateModeMain.bosatsu \
c --main Bosatsu/IO/CreateModeMain --outdir "$tmp_dir"
cc $GC_CFLAGS -O2 -Wall -c "$tmp_dir/output.c" -o "$tmp_dir/create_mode_output.o"
cc $GC_CFLAGS -O2 -Wall -o "$tmp_dir/create_mode_exe" \
"$tmp_dir/create_mode_output.o" \
"$tmp_dir/bosatsu_runtime.o" \
"$tmp_dir/bosatsu_ext_Bosatsu_l_Predef.o" \
"$tmp_dir/bosatsu_ext_Bosatsu_l_Prog.o" \
"$tmp_dir/bosatsu_ext_Bosatsu_l_IO_l_Core.o" \
"$tmp_dir/bosatsu_ext_Bosatsu_l_IO_l_Bytes.o" \
"$tmp_dir/bosatsu_ext_Bosatsu_l_Collection_l_Array.o" \
"$tmp_dir/bosatsu_ext_Bosatsu_l_Num_l_Float64.o" \
$GC_LIBS -lm
create_mode_output=$("$tmp_dir/create_mode_exe")
check_create_mode_output "$create_mode_output"