Skip to content

Commit 2db59c3

Browse files
scripts/test.py: cibw_do_test_project(): restored missing call of longjmp().
Also enable asserts and improve diagnostics.
1 parent 5925c14 commit 2db59c3

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

scripts/test.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -948,7 +948,7 @@ def build():
948948
cc_base, _ = pipcl.base_compiler(cpp=True)
949949
ld_base, _ = pipcl.base_linker(cpp=True)
950950
pipcl.run(f'mkdir -p {testdir}/build')
951-
pipcl.run(f'{{cc_base}} -DNDEBUG -fPIC -c -o {testdir}/build/qwerty.o {testdir}/qwerty.cpp')
951+
pipcl.run(f'{{cc_base}} -fPIC -c -o {testdir}/build/qwerty.o {testdir}/qwerty.cpp')
952952
pipcl.run(f'{{ld_base}} -o {testdir}/build/libqwerty.so {testdir}/build/qwerty.o')
953953
954954
so_leaf = pipcl.build_extension(
@@ -957,6 +957,7 @@ def build():
957957
outdir = 'build',
958958
libpaths = '{testdir}/build',
959959
libs = ['qwerty'],
960+
optimise = False,
960961
)
961962
962963
return [
@@ -984,27 +985,29 @@ def build():
984985
with open(f'{testdir}/foo.i', 'w') as f:
985986
f.write(textwrap.dedent('''
986987
%{
988+
#include <stdexcept>
989+
990+
#include <assert.h>
987991
#include <setjmp.h>
988992
#include <stdio.h>
989993
#include <string.h>
990-
#include <stdexcept>
991994
992995
int qwerty(void);
993996
994997
static sigjmp_buf jmpbuf;
995998
static int bar0(const char* text)
996999
{
997-
printf("bar(): text: %s\\n", text);
1000+
printf("bar0(): text: %s\\n", text);
9981001
9991002
int q = qwerty();
1000-
printf("bar(): q=%i\\n", q);
1003+
printf("bar0(): q=%i\\n", q);
10011004
10021005
int len = (int) strlen(text);
1003-
printf("bar(): len=%i\\\\n", len);
1004-
//printf("calling longjmp().\\n");
1005-
//longjmp(jmpbuf, 1);
1006+
printf("bar0(): len=%i\\n", len);
1007+
printf("bar0(): calling longjmp().\\n");
10061008
fflush(stdout);
1007-
return len;
1009+
longjmp(jmpbuf, 1);
1010+
assert(0);
10081011
}
10091012
int bar1(const char* text)
10101013
{
@@ -1015,11 +1018,10 @@ def build():
10151018
}
10161019
else
10171020
{
1018-
printf("setjmp() returned non-zero.\\n");
1021+
printf("bar1(): setjmp() returned non-zero.\\n");
10191022
throw std::runtime_error("deliberate exception");
10201023
}
1021-
throw std::runtime_error("deliberate exception");
1022-
return ret;
1024+
assert(0);
10231025
}
10241026
int bar(const char* text)
10251027
{
@@ -1030,7 +1032,7 @@ def build():
10301032
}
10311033
catch(std::exception& e)
10321034
{
1033-
printf("Received exception: %s\\n", e.what());
1035+
printf("bar1(): received exception: %s\\n", e.what());
10341036
}
10351037
return ret;
10361038
}

0 commit comments

Comments
 (0)