-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwscript
100 lines (77 loc) · 2.76 KB
/
wscript
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#! /usr/bin/env python
# encoding: utf-8
import shutil
import os
import platform
import waflib
import hashlib
import os.path
from waflib.Build import BuildContext
APPNAME = "tunnel"
VERSION = "17.0.0"
def options(opt):
if not opt.is_toplevel():
return
opt.add_option(
"--pytest_temp",
default="pytest_temp",
help="Set the path where pytest executes the tests",
)
def configure(conf):
conf.set_cxx_std(17)
if not conf.is_toplevel():
return
def build(bld):
bld.stlib(
features="cxx",
source=bld.path.ant_glob("src/**/*.cpp"),
target="tunnel",
use=["platform_includes", "poke"],
export_includes=["src"],
)
if bld.is_toplevel():
# Collect the source files but exclude the platform specific ones
sources = bld.path.ant_glob(
"test/src/**/*.cpp", excl=["test/**/platform_*/**/*.cpp"]
) + bld.path.ant_glob("test/src/**/*.cc")
if platform.system() == "Linux":
sources += bld.path.ant_glob("test/src/**/platform_linux/**/*.cpp")
elif platform.system() == "Darwin":
sources += bld.path.ant_glob("test/src/**/platform_macos/**/*.cpp")
sources += bld.path.ant_glob("test/src/**/platform_unsupported/**/*.cpp")
bld.program(
features="cxx test",
source=["test/tunnel_tests.cpp"] + sources,
target="tunnel_tests",
use=["tunnel", "gtest"],
)
if platform.system() == "Linux" or platform.system() == "Darwin":
bld.recurse("examples")
bld.recurse("apps/app/")
class IntegrationContext(BuildContext):
cmd = "integration_test"
fun = "integration_test"
def integration_test(ctx):
# Test only for linux
if not ctx.is_mkspec_platform("linux"):
return
tunnel_app_binary = os.path.relpath(
os.path.join(ctx.out_dir, "apps", "app", "tunnel_test_app")
)
if not os.path.exists(tunnel_app_binary):
ctx.fatal(
f"Cannot find tunnel binary in {tunnel_app_binary}, did you run 'waf build'?"
)
venv = ctx.create_virtualenv(name="pytest-venv", overwrite=True)
# To update the requirements.txt just delete it - a fresh one
# will be generated from test/integration/requirements.in
if not os.path.isfile("test/integration/requirements.txt"):
venv.run("python -m pip install pip-tools")
venv.run("pip-compile test/integration/requirements.in")
cmd_options = ""
if ctx.has_tool_option("filter"):
cmd_options += f"-k '{ctx.get_tool_option('filter')}'"
venv.run("python -m pip install -r test/integration/requirements.txt")
venv.run(
f"pytest -xrA --tunnel-app={tunnel_app_binary} {cmd_options} test/integration"
)