Skip to content

Commit 7472bb1

Browse files
committed
small changes to be able to run test on MacOs
set LC_ALL=C to avoid utf8 warning on macos generate the tempdir differently so this working on Macos ( still working on linux ) keep the tempdir when we have a failure add a regeression test for readlink
1 parent cfb24ea commit 7472bb1

File tree

3 files changed

+41
-15
lines changed

3 files changed

+41
-15
lines changed

tests/custom/03_stdlib/62_loadfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,9 @@ Test loading precompiled bytecode
152152

153153
-- Testcase --
154154
{%
155-
import { readlink } from 'fs';
156155

157-
system(`${readlink('/proc/self/exe')} -T, -c -o ./files/test7.uc -e 'Hello world\n'`);
156+
cur_exe=getenv('ucode_bin');
157+
system(`${cur_exe} -T, -c -o ./files/test7.uc -e 'Hello world\n'`);
158158

159159
let fn = loadfile('./files/test7.uc');
160160
fn();

tests/custom/03_stdlib/69_readlink

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
The `readlink()` function will follow symbolink link to find the real name of the file
2+
input to compile from the specified file path instead.
3+
4+
-- Testcase --
5+
{%
6+
import { readlink } from 'fs';
7+
system('touch ./files/test_69.txt');
8+
system('ls -1 ./files/test_69.txt');
9+
system('ln -s ./files/test_69.txt ./files/test_symlink.txt');
10+
system('ls -1 ./files/test_symlink.txt');
11+
12+
final_name=readlink('./files/test_symlink.txt');
13+
print(final_name,"\n");
14+
%}
15+
-- End --
16+
17+
-- File test_69.txt --
18+
test 69 in test_69.txt
19+
-- End --
20+
21+
-- Expect stdout --
22+
./files/test_69.txt
23+
./files/test_symlink.txt
24+
./files/test_69.txt
25+
-- End --

tests/custom/run_tests.sh

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@ else
66
readlink=readlink
77
fi
88

9+
export LC_ALL=C
10+
911
testdir=$(dirname "$0")
1012
topdir=$($readlink -f "$testdir/../..")
1113

1214
line='........................................'
13-
ucode_bin=${UCODE_BIN:-"$topdir/ucode"}
14-
ucode_lib=${UCODE_LIB:-"$topdir"}
15+
export ucode_bin=${UCODE_BIN:-"$topdir/ucode"}
16+
export ucode_lib=${UCODE_LIB:-"$topdir"}
1517

1618
extract_sections() {
1719
local file=$1
@@ -142,22 +144,22 @@ run_test() {
142144

143145
printf "%s %s " "$name" "${line:${#name}}"
144146

145-
mkdir "/tmp/test.$$"
146-
147-
extract_sections "$file" "/tmp/test.$$"
147+
dir_4_test=$($readlink -f $(mktemp -d /tmp/rt.XXXX ))
148+
149+
extract_sections "$file" "${dir_4_test}"
148150
tests=$?
149151

150-
[ -f "/tmp/test.$$/001.in" ] && testcase_first=1
152+
[ -f "${dir_4_test}/001.in" ] && testcase_first=1
151153

152-
for res in "/tmp/test.$$/"[0-9]*; do
154+
for res in "${dir_4_test}/"[0-9]*; do
153155
case "$res" in
154156
*.in)
155157
count=$((count + 1))
156158

157159
if [ $testcase_first = 1 ]; then
158160
# Flush previous test
159161
if [ -n "$ein" ]; then
160-
run_testcase $count "/tmp/test.$$" "$ein" "$eout" "$eerr" "$ecode" "$eargs" "$evars" || failed=$((failed + 1))
162+
run_testcase $count "${dir_4_test}" "$ein" "$eout" "$eerr" "$ecode" "$eargs" "$evars" || failed=$((failed + 1))
161163
eout=""
162164
eerr=""
163165
ecode=""
@@ -167,7 +169,7 @@ run_test() {
167169

168170
ein=$res
169171
else
170-
run_testcase $count "/tmp/test.$$" "$res" "$eout" "$eerr" "$ecode" "$eargs" "$evars" || failed=$((failed + 1))
172+
run_testcase $count "${dir_4_test}" "$res" "$eout" "$eerr" "$ecode" "$eargs" "$evars" || failed=$((failed + 1))
171173

172174
eout=""
173175
eerr=""
@@ -187,15 +189,14 @@ run_test() {
187189

188190
# Flush last test
189191
if [ $testcase_first = 1 ] && [ -n "$eout$eerr$ecode" ]; then
190-
run_testcase $count "/tmp/test.$$" "$ein" "$eout" "$eerr" "$ecode" "$eargs" "$evars" || failed=$((failed + 1))
192+
run_testcase $count "${dir_4_test}" "$ein" "$eout" "$eerr" "$ecode" "$eargs" "$evars" || failed=$((failed + 1))
191193
fi
192194

193-
rm -r "/tmp/test.$$"
194-
195195
if [ $failed = 0 ]; then
196196
printf "OK\n"
197+
rm -r "${dir_4_test}"
197198
else
198-
printf "%s %s FAILED (%d/%d)\n" "$name" "${line:${#name}}" $failed $tests
199+
printf "%s %s FAILED (%d/%d)\ntemp dir was %s\n" "$name" "${line:${#name}}" $failed $tests $dir_4_test
199200
fi
200201

201202
return $failed

0 commit comments

Comments
 (0)