Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gwenaël Samain
cython
Commits
ef6d1961
Commit
ef6d1961
authored
7 years ago
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'embray-cygwin-tests'
parents
1c9e174d
7da5f348
master
nogil_cypclass_acthon_on_rc8v3
snippets_article
nogil_cypclass_rc8
nogil_cypclass_lock_on_rc8v3
No related merge requests found
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
117 additions
and
35 deletions
+117
-35
Cython/Compiler/Code.py
Cython/Compiler/Code.py
+2
-1
Cython/Debugger/Tests/TestLibCython.py
Cython/Debugger/Tests/TestLibCython.py
+2
-0
Cython/Debugger/Tests/cfuncs.h
Cython/Debugger/Tests/cfuncs.h
+1
-0
Cython/Debugger/Tests/codefile
Cython/Debugger/Tests/codefile
+1
-1
runtests.py
runtests.py
+44
-9
tests/compile/callingconvention.srctree
tests/compile/callingconvention.srctree
+10
-1
tests/compile/declarations.srctree
tests/compile/declarations.srctree
+10
-1
tests/cygwin_bugs.txt
tests/cygwin_bugs.txt
+5
-0
tests/run/complex_numbers_T305.pyx
tests/run/complex_numbers_T305.pyx
+3
-4
tests/run/complex_numbers_T305_long_double.pyx
tests/run/complex_numbers_T305_long_double.pyx
+13
-0
tests/run/complex_numbers_c89_T398_long_double.pyx
tests/run/complex_numbers_c89_T398_long_double.pyx
+4
-0
tests/run/cpdef_extern_func.pyx
tests/run/cpdef_extern_func.pyx
+1
-0
tests/run/int_float_builtins_as_casts_T400.pyx
tests/run/int_float_builtins_as_casts_T400.pyx
+0
-18
tests/run/int_float_builtins_as_casts_T400_long_double.pyx
tests/run/int_float_builtins_as_casts_T400_long_double.pyx
+21
-0
No files found.
Cython/Compiler/Code.py
View file @
ef6d1961
...
...
@@ -13,6 +13,7 @@ cython.declare(os=object, re=object, operator=object,
import
os
import
re
import
shutil
import
sys
import
operator
import
textwrap
...
...
@@ -1737,7 +1738,7 @@ class CCodeWriter(object):
tmp_path
=
'%s.tmp%s'
%
(
path
,
os
.
getpid
())
with
closing
(
Utils
.
open_new_file
(
tmp_path
))
as
f
:
f
.
write
(
code
)
os
.
renam
e
(
tmp_path
,
path
)
shutil
.
mov
e
(
tmp_path
,
path
)
code
=
'#include "%s"
\
n
'
%
path
self
.
put
(
code
)
...
...
This diff is collapsed.
Click to expand it.
Cython/Debugger/Tests/TestLibCython.py
View file @
ef6d1961
...
...
@@ -90,6 +90,8 @@ class DebuggerTestCase(unittest.TestCase):
shutil
.
copy
(
codefile
,
self
.
destfile
)
shutil
.
copy
(
cfuncs_file
,
self
.
cfuncs_destfile
+
'.c'
)
shutil
.
copy
(
cfuncs_file
.
replace
(
'.c'
,
'.h'
),
self
.
cfuncs_destfile
+
'.h'
)
compiler
=
ccompiler
.
new_compiler
()
compiler
.
compile
([
'cfuncs.c'
],
debug
=
True
,
extra_postargs
=
[
'-fPIC'
])
...
...
This diff is collapsed.
Click to expand it.
Cython/Debugger/Tests/cfuncs.h
0 → 100644
View file @
ef6d1961
void
some_c_function
(
void
);
This diff is collapsed.
Click to expand it.
Cython/Debugger/Tests/codefile
View file @
ef6d1961
cdef extern from "stdio.h":
int puts(char *s)
cdef extern:
cdef extern
from "cfuncs.h"
:
void some_c_function()
import os
...
...
This diff is collapsed.
Click to expand it.
runtests.py
View file @
ef6d1961
#!/usr/bin/env python
import
atexit
import
os
import
sys
import
re
...
...
@@ -70,6 +71,24 @@ CY3_DIR = None
from
distutils.command.build_ext
import
build_ext
as
_build_ext
from
distutils
import
sysconfig
_to_clean
=
[]
@
atexit
.
register
def
_cleanup_files
():
"""
This is only used on Cygwin to clean up shared libraries that are unsafe
to delete while the test suite is running.
"""
for
filename
in
_to_clean
:
if
os
.
path
.
isdir
(
filename
):
shutil
.
rmtree
(
filename
,
ignore_errors
=
True
)
else
:
try
:
os
.
remove
(
filename
)
except
OSError
:
pass
def
get_distutils_distro
(
_cache
=
[]):
if
_cache
:
...
...
@@ -678,8 +697,10 @@ class CythonCompileTestCase(unittest.TestCase):
cleanup = self.cleanup_failures or self.success
cleanup_c_files = WITH_CYTHON and self.cleanup_workdir and cleanup
cleanup_lib_files = self.cleanup_sharedlibs and cleanup
is_cygwin = sys.platform == 'cygwin'
if os.path.exists(self.workdir):
if cleanup_c_files and cleanup_lib_files:
if cleanup_c_files and cleanup_lib_files
and not is_cygwin
:
shutil.rmtree(self.workdir, ignore_errors=True)
else:
for rmfile in os.listdir(self.workdir):
...
...
@@ -688,17 +709,28 @@ class CythonCompileTestCase(unittest.TestCase):
rmfile[-4:] == ".cpp" or
rmfile.endswith(".html") and rmfile.startswith(self.module)):
continue
if not cleanup_lib_files and (rmfile.endswith(".so") or rmfile.endswith(".dll")):
is_shared_obj = rmfile.endswith(".so") or rmfile.endswith(".dll")
if not cleanup_lib_files and is_shared_obj:
continue
try:
rmfile = os.path.join(self.workdir, rmfile)
if os.path.isdir(rmfile):
shutil.rmtree(rmfile, ignore_errors=True)
elif is_cygwin and is_shared_obj:
# Delete later
_to_clean.append(rmfile)
else:
os.remove(rmfile)
except IOError:
pass
if cleanup_c_files and cleanup_lib_files and is_cygwin:
# Finally, remove the work dir itself
_to_clean.append(self.workdir)
def runTest(self):
self.success = False
self.runCompileTest()
...
...
@@ -828,10 +860,7 @@ class CythonCompileTestCase(unittest.TestCase):
build_extension.compiler = COMPILER
ext_compile_flags = CFLAGS[:]
compiler = COMPILER or sysconfig.get_config_var('CC')
if self.language == 'c' and compiler == 'gcc':
ext_compile_flags.extend(['-std=c89', '-pedantic'])
if build_extension.compiler == 'mingw32':
ext_compile_flags.append('-Wno-format')
if extra_extension_args is None:
...
...
@@ -1459,7 +1488,6 @@ class EmbedTest(unittest.TestCase):
os.chdir(self.old_dir)
def test_embed(self):
from distutils import sysconfig
libname = sysconfig.get_config_var('LIBRARY')
libdir = sysconfig.get_config_var('LIBDIR')
if not os.path.isdir(libdir) or libname not in os.listdir(libdir):
...
...
@@ -1980,10 +2008,17 @@ def runtests(options, cmd_args, coverage=None):
exclude_selectors.append(ShardExcludeSelector(options.shard_num, options.shard_count))
if not test_bugs:
bug_files = [
('bugs.txt', True),
('pypy_bugs.txt', IS_PYPY),
('windows_bugs.txt', sys.platform == 'win32'),
('cygwin_bugs.txt', sys.platform == 'cygwin')
]
exclude_selectors += [
FileListExcluder(os.path.join(ROOTDIR, bugs_file_name),
verbose=verbose_excludes)
for bugs_file_name in ['bugs.txt'] + (['pypy_bugs.txt'] if IS_PYPY else []) +
(['windows_bugs.txt'] if sys.platform == 'win32' else [])
FileListExcluder(os.path.join(ROOTDIR, bugs_file_name),
verbose=verbose_excludes)
for bugs_file_name, condition in bug_files if condition
]
if sys.platform in ['win32', 'cygwin'] and sys.version_info < (2,6):
...
...
This diff is collapsed.
Click to expand it.
tests/compile/callingconvention.srctree
View file @
ef6d1961
...
...
@@ -17,7 +17,7 @@ setup(
######## callingconvention.pyx ########
# mode: compile
cdef extern from "
external_
callingconvention.h":
cdef extern from "callingconvention.h":
pass
cdef extern int f1()
...
...
@@ -35,10 +35,19 @@ p2 = f2
p3 = f3
p4 = f4
######## callingconvention.h ########
#define DLL_EXPORT
#include "external_callingconvention.h"
######## external_callingconvention.h ########
#ifndef DL_IMPORT
#define DL_IMPORT(t) t
#elif defined(DLL_EXPORT)
#define DL_IMPORT(t) DL_EXPORT(t)
#endif
#ifdef __cplusplus
...
...
This diff is collapsed.
Click to expand it.
tests/compile/declarations.srctree
View file @
ef6d1961
...
...
@@ -17,7 +17,7 @@ setup(
######## declarations.pyx ########
# mode: compile
cdef extern from "
external_
declarations.h":
cdef extern from "declarations.h":
pass
cdef extern char *cp
...
...
@@ -48,10 +48,19 @@ cdef char *g():
f()
g()
######## declarations.h ########
#define DLL_EXPORT
#include "external_declarations.h"
######## external_declarations.h ########
#ifndef DL_IMPORT
#define DL_IMPORT(t) t
#elif defined(DLL_EXPORT)
#define DL_IMPORT(t) DL_EXPORT(t)
#endif
#ifdef __cplusplus
...
...
This diff is collapsed.
Click to expand it.
tests/cygwin_bugs.txt
0 → 100644
View file @
ef6d1961
module_api
complex_numbers_c89_T398_long_double
complex_numbers_T305_long_double
int_float_builtins_as_casts_T400_long_double
This diff is collapsed.
Click to expand it.
tests/run/complex_numbers_T305.pyx
View file @
ef6d1961
...
...
@@ -5,14 +5,13 @@ cimport cython
def
test_object_conversion
(
o
):
"""
>>> test_object_conversion(2)
((2+0j), (2+0j)
, (2+0j)
)
((2+0j), (2+0j))
>>> test_object_conversion(2j - 0.5)
((-0.5+2j), (-0.5+2j)
, (-0.5+2j)
)
((-0.5+2j), (-0.5+2j))
"""
cdef
float
complex
a
=
o
cdef
double
complex
b
=
o
cdef
long
double
complex
c
=
o
return
(
a
,
b
,
c
)
return
(
a
,
b
)
def
test_arithmetic
(
double
complex
z
,
double
complex
w
):
"""
...
...
This diff is collapsed.
Click to expand it.
tests/run/complex_numbers_T305_long_double.pyx
0 → 100644
View file @
ef6d1961
# ticket: 305
cimport
cython
def
test_object_conversion
(
o
):
"""
>>> test_object_conversion(2)
(2+0j)
>>> test_object_conversion(2j - 0.5)
(-0.5+2j)
"""
cdef
long
double
complex
a
=
o
return
a
This diff is collapsed.
Click to expand it.
tests/run/complex_numbers_c89_T398_long_double.pyx
0 → 100644
View file @
ef6d1961
# ticket: 398
cdef
extern
from
"complex_numbers_c89_T398.h"
:
pass
include
"complex_numbers_T305_long_double.pyx"
This diff is collapsed.
Click to expand it.
tests/run/cpdef_extern_func.pyx
View file @
ef6d1961
# cython: c_string_type=str
# cython: c_string_encoding=ascii
# distutils: extra_compile_args=-fpermissive
__doc__
=
"""
>>> sqrt(1)
...
...
This diff is collapsed.
Click to expand it.
tests/run/int_float_builtins_as_casts_T400.pyx
View file @
ef6d1961
...
...
@@ -187,24 +187,6 @@ def double_to_float_int(double x):
return
r
@
cython
.
test_fail_if_path_exists
(
"//SingleAssignmentNode//TypecastNode"
)
@
cython
.
test_assert_path_exists
(
"//PythonCapiCallNode"
,
"//PythonCapiCallNode/PythonCapiFunctionNode/@cname = '__Pyx_truncl'"
,
)
def
long_double_to_float_int
(
long
double
x
):
"""
>>> long_double_to_float_int(4.1)
4.0
>>> long_double_to_float_int(-4.1)
-4.0
>>> long_double_to_float_int(4)
4.0
"""
cdef
float
r
=
int
(
x
)
return
r
@
cython
.
test_fail_if_path_exists
(
"//SimpleCallNode"
)
@
cython
.
test_assert_path_exists
(
"//PythonCapiCallNode"
)
def
object_float
(
x
):
...
...
This diff is collapsed.
Click to expand it.
tests/run/int_float_builtins_as_casts_T400_long_double.pyx
0 → 100644
View file @
ef6d1961
# ticket: 400
cimport
cython
@
cython
.
test_fail_if_path_exists
(
"//SingleAssignmentNode//TypecastNode"
)
@
cython
.
test_assert_path_exists
(
"//PythonCapiCallNode"
,
"//PythonCapiCallNode/PythonCapiFunctionNode/@cname = '__Pyx_truncl'"
,
)
def
long_double_to_float_int
(
long
double
x
):
"""
>>> long_double_to_float_int(4.1)
4.0
>>> long_double_to_float_int(-4.1)
-4.0
>>> long_double_to_float_int(4)
4.0
"""
cdef
float
r
=
int
(
x
)
return
r
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment