Repository navigation
Expand file tree
/
Copy pathtest_csharp_bindings.py
More file actions
executable file
·86 lines (63 loc) · 3 KB
/
Copy pathtest_csharp_bindings.py
File metadata and controls
executable file
·86 lines (63 loc) · 3 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
86
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
C# Bindings Tester
Copyright (C) 2012-2018 Matthias Bolte <matthias@tinkerforge.com>
test_csharp_bindings.py: Tests the C# bindings
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public
License along with this program; if not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
"""
import sys
if sys.hexversion < 0x3040000:
print('Python >= 3.4 required')
sys.exit(1)
import os
import shutil
import importlib.util
import importlib.machinery
def create_generators_module():
generators_dir = os.path.split(os.path.dirname(os.path.realpath(__file__)))[0]
if sys.hexversion < 0x3050000:
generators_module = importlib.machinery.SourceFileLoader('generators', os.path.join(generators_dir, '__init__.py')).load_module()
else:
generators_spec = importlib.util.spec_from_file_location('generators', os.path.join(generators_dir, '__init__.py'))
generators_module = importlib.util.module_from_spec(generators_spec)
generators_spec.loader.exec_module(generators_module)
sys.modules['generators'] = generators_module
if 'generators' not in sys.modules:
create_generators_module()
from generators import common
class CSharpExamplesTester(common.Tester):
def __init__(self, root_dir, extra_paths):
common.Tester.__init__(self, 'csharp', '.cs', root_dir, extra_paths=extra_paths)
def test(self, cookie, tmp_dir, scratch_dir, path, extra):
if extra:
shutil.copy(path, tmp_dir)
path = os.path.join(tmp_dir, os.path.split(path)[-1])
shutil.copy(os.path.join(self.root_dir, 'Example.csproj'), scratch_dir)
shutil.copy(os.path.join(tmp_dir, 'Tinkerforge.dll'), scratch_dir)
shutil.copy(path, scratch_dir)
args = ['dotnet',
'build',
'-c',
'Release']
self.execute(cookie, args, cwd=scratch_dir)
def test(root_dir):
extra_paths = [os.path.join(root_dir, '../../weather-station/button_control/csharp/WeatherStationButton.cs'),
os.path.join(root_dir, '../../weather-station/write_to_lcd/csharp/WeatherStation.cs'),
os.path.join(root_dir, '../../hardware-hacking/remote_switch/csharp/RemoteSwitch.cs'),
os.path.join(root_dir, '../../hardware-hacking/smoke_detector/csharp/SmokeDetector.cs')]
return CSharpExamplesTester(root_dir, extra_paths).run()
if __name__ == '__main__':
common.dockerize('csharp', __file__)
test(os.getcwd())