-
Notifications
You must be signed in to change notification settings - Fork 2
/
test_toolchains.py
74 lines (61 loc) · 2.2 KB
/
test_toolchains.py
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
# coding=utf-8
#
# _pylint: skip-file
# pylint: disable = missing-docstring, invalid-name
"""
Copyright (c) 2019, Alexander Magola. All rights reserved.
license: BSD 3-Clause License, see LICENSE for more details.
"""
import itertools
import pytest
from zm.error import ZenMakeError
from zm import toolchains
# pylint: disable = unused-import
from zm.features import c, cxx, asm
# pylint: enable = unused-import
COMPILERS_MAP = {
'c' : {
'windows': ['msvc', 'gcc', 'clang'],
'darwin': ['clang', 'gcc'],
'linux': ['gcc', 'clang', 'icc'],
'default': ['clang', 'gcc'],
},
'cxx' : {
'windows': ['msvc', 'g++', 'clang++'],
'darwin': ['clang++', 'g++'],
'linux': ['g++', 'clang++', 'icpc'],
'default': ['clang++', 'g++'],
},
'asm' : {
'default':['gas', 'nasm'],
},
}
SUPPORTED_LANGS = COMPILERS_MAP.keys()
def testGetNames():
for lang in SUPPORTED_LANGS:
langCompiler = COMPILERS_MAP[lang]
for _platform in ('linux', 'windows', 'darwin'):
compilers = toolchains.getNames(lang, _platform)
# to force covering of cache
_compilers = toolchains.getNames(lang, _platform)
assert _compilers == compilers
expected = langCompiler.get(_platform, langCompiler['default'])
assert set(compilers) == set(expected)
compilers = toolchains.getNames(lang, 'all')
# to force covering of cache
_compilers = toolchains.getNames(lang, 'all')
assert _compilers == compilers
assert set(compilers) >= \
set(itertools.chain(*langCompiler.values()))
with pytest.raises(ZenMakeError):
toolchains.getNames('')
with pytest.raises(ZenMakeError):
toolchains.getNames('invalid lang')
def testGetAllNames():
for platform in ('linux', 'windows', 'darwin', 'all'):
expectedCompilers = []
for lang in SUPPORTED_LANGS:
expectedCompilers.extend(toolchains.getNames(lang, platform))
expectedCompilers = list(set(expectedCompilers))
assert sorted(toolchains.getAllNames(platform)) == \
sorted(expectedCompilers)