Skip to content

Commit 7e29bd1

Browse files
author
Jonathan Kliem
authored
Merge pull request #1 from sagemath/fix-32bit-tests
add 32bit github tests and fix failures
2 parents 24f00d9 + bbdd6b8 commit 7e29bd1

File tree

5 files changed

+26
-10
lines changed

5 files changed

+26
-10
lines changed

Diff for: .github/workflows/main.yml

+9-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,13 @@ jobs:
1515
fail-fast: false
1616
matrix:
1717
os: [ubuntu-latest, macos-latest, windows-latest]
18-
python-version: [3.6, 3.7, 3.8, 3.9]
18+
python-version: [3.6, 3.7, 3.8, 3.9, 3.10.0-rc.2]
19+
architecture: [x64, x86]
20+
exclude:
21+
- os: ubuntu-latest
22+
architecture: x86
23+
- os: macos-latest
24+
architecture: x86
1925
steps:
2026
- name: Set up the repository
2127
uses: actions/checkout@v2
@@ -26,6 +32,7 @@ jobs:
2632
uses: actions/setup-python@v2
2733
with:
2834
python-version: ${{ matrix.python-version }}
35+
architecture: ${{ matrix.architecture }}
2936
- name: Install dependencies
3037
run: |
3138
python -m pip install --upgrade pip
@@ -36,5 +43,5 @@ jobs:
3643
- name: Local build
3744
run: |
3845
python setup.py build_ext -i
39-
python test.py
46+
python test.py || exit 1
4047
git clean -xfd

Diff for: README.md

+6
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,9 @@ It provides a single extension class `MemoryAllocator` with `cdef` methods
1616

1717
Memory is freed when the instance of `MemoryAllocator` is deallocated.
1818
On failure to allocate the memory, a proper error is raised.
19+
20+
# Changelog
21+
22+
## 0.1.1
23+
24+
- Fixed doctests on 32bit systems.

Diff for: cydoctest.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,6 @@ def testmod(m=None, *args, **kwargs):
6060
All other arguments are passed directly to doctest.testmod().
6161
"""
6262
fix_module_doctest(m)
63-
result = doctest.testmod(m, *args, **kwargs)
63+
result = doctest.testmod(m, optionflags=doctest.ELLIPSIS, *args, **kwargs)
6464
if result.failed > 0:
6565
sys.exit('%d test(s) failed' % result.failed)

Diff for: memory_allocator/test.pyx

+9-6
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ cdef class TestMemoryAllocator():
1414
>>> from memory_allocator.test import TestMemoryAllocator
1515
>>> mem = TestMemoryAllocator()
1616
>>> _ = mem.malloc(100)
17-
>>> mem.malloc(2**63)
17+
>>> mem.malloc(mem.size_t_max())
1818
Traceback (most recent call last):
1919
...
20-
MemoryError: failed to allocate 9223372036854775808 bytes
20+
MemoryError: failed to allocate ... bytes
2121
"""
2222
return <size_t> self.mem.malloc(size)
2323

@@ -28,10 +28,10 @@ cdef class TestMemoryAllocator():
2828
>>> from memory_allocator.test import TestMemoryAllocator
2929
>>> mem = TestMemoryAllocator()
3030
>>> _ = mem.calloc(100, 10)
31-
>>> mem.calloc(2**63, 1)
31+
>>> mem.calloc(mem.size_t_max(), 1)
3232
Traceback (most recent call last):
3333
...
34-
MemoryError: failed to allocate 9223372036854775808 * 1 bytes
34+
MemoryError: failed to allocate ... * 1 bytes
3535
"""
3636
return <size_t> self.mem.calloc(nmemb, size)
3737

@@ -42,10 +42,10 @@ cdef class TestMemoryAllocator():
4242
>>> from memory_allocator.test import TestMemoryAllocator
4343
>>> mem = TestMemoryAllocator()
4444
>>> _ = mem.allocarray(100, 10)
45-
>>> mem.allocarray(2**63, 1)
45+
>>> mem.allocarray(mem.size_t_max(), 1)
4646
Traceback (most recent call last):
4747
...
48-
MemoryError: failed to allocate 9223372036854775808 * 1 bytes
48+
MemoryError: failed to allocate ... * 1 bytes
4949
"""
5050
return <size_t> self.mem.allocarray(nmemb, size)
5151

@@ -142,3 +142,6 @@ cdef class TestMemoryAllocator():
142142

143143
def size(self):
144144
return self.mem.size
145+
146+
def size_t_max(self):
147+
return <size_t> -1

Diff for: setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def run(self):
2626

2727
setup(
2828
name='memory_allocator',
29-
version='0.1.0',
29+
version='0.1.1',
3030
description='An extension class to allocate memory easily with cython',
3131
long_description=long_description,
3232
long_description_content_type='text/markdown',

0 commit comments

Comments
 (0)