forked from JuliaPy/pyjulia
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_sysimage.py
More file actions
85 lines (67 loc) · 2.37 KB
/
test_sysimage.py
File metadata and controls
85 lines (67 loc) · 2.37 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
import os
import shutil
from subprocess import check_call
import pytest
from julia.sysimage import build_sysimage
from ..tools import build_pycall
from .test_compatible_exe import runcode
from .utils import only_in_ci, skip_in_apple, skip_in_windows
def skip_early_julia_versions(juliainfo):
if juliainfo.version_info < (1, 3, 1):
pytest.skip("Julia < 1.3.1 is not supported")
def assert_sample_julia_code_runs(juliainfo, sysimage_path):
very_random_string = "4903dc03-950f-4a54-98a3-c57a354b62df"
proc = runcode(
"""
from julia.api import Julia
sysimage_path = {sysimage_path!r}
very_random_string = {very_random_string!r}
jl = Julia(
debug=True,
sysimage=sysimage_path,
runtime={juliainfo.julia!r},
)
from julia import Main
Main.println(very_random_string)
""".format(
juliainfo=juliainfo,
sysimage_path=sysimage_path,
very_random_string=very_random_string,
)
)
assert very_random_string in proc.stdout
@pytest.mark.julia
@only_in_ci
@skip_in_windows
@skip_in_apple
@pytest.mark.parametrize("with_pycall_cache", [False, True])
def test_build_and_load(tmpdir, juliainfo, with_pycall_cache):
skip_early_julia_versions(juliainfo)
if with_pycall_cache:
build_pycall(julia=juliainfo.julia)
check_call([juliainfo.julia, "--startup-file=no", "-e", "using PyCall"])
else:
# TODO: don't remove user's compile cache
cachepath = os.path.join(
os.path.expanduser("~"),
".julia",
"compiled",
"v{}.{}".format(juliainfo.version_major, juliainfo.version_minor),
"PyCall",
)
shutil.rmtree(cachepath)
sysimage_path = str(tmpdir.join("sys.so"))
build_sysimage(sysimage_path, julia=juliainfo.julia)
assert_sample_julia_code_runs(juliainfo, sysimage_path)
@pytest.mark.julia
@only_in_ci
@skip_in_windows # Avoid "LVM ERROR: out of memory"
@skip_in_apple
def test_build_with_basesysimage_and_load(tmpdir, juliainfo):
skip_early_julia_versions(juliainfo)
sysimage_path = str(tmpdir.join("sys.so"))
base_sysimage_path = juliainfo.sysimage
build_sysimage(
sysimage_path, julia=juliainfo.julia, base_sysimage=base_sysimage_path
)
assert_sample_julia_code_runs(juliainfo, sysimage_path)