Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable Windows CI tests #81

Merged
merged 1 commit into from
Jul 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions continuous-integration/windows/setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import tempfile
import sys
import subprocess
import shutil
from pathlib import Path


Expand Down Expand Up @@ -42,9 +43,33 @@ def _install_zivid_sdk():
_run_process((str(zivid_installer), "/S"))


def _install_intel_opencl_runtime():
import requests # pylint: disable=import-outside-toplevel

with tempfile.TemporaryDirectory() as temp_dir:
intel_opencl_runtime_url = "https://www.dropbox.com/s/09bk2nx31hzrupf/opencl_runtime_18.1_x64_setup-20200625-090300.msi?raw=1"
print("Downloading {}".format(intel_opencl_runtime_url), flush=True)
opencl_runtime = Path(temp_dir) / "opencl_runtime.msi"
response = requests.get(intel_opencl_runtime_url)
opencl_runtime.write_bytes(response.content)
print("Installing {}".format(opencl_runtime), flush=True)
_run_process(("msiexec", "/i", str(opencl_runtime), "/passive"))


def _write_zivid_cpu_configuration_file():
api_config = Path() / "ZividAPIConfig.yml"
target_location = Path(
r"C:\Users\VssAdministrator\AppData\Local\Zivid\API\Config.yml"
)
target_location.parent.mkdir(parents=True, exist_ok=True)
shutil.copy(str(api_config), str(target_location))


def _main():
_install_pip_dependencies()
_install_intel_opencl_runtime()
_install_zivid_sdk()
_write_zivid_cpu_configuration_file()


if __name__ == "__main__":
Expand Down
39 changes: 29 additions & 10 deletions continuous-integration/windows/test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import argparse
import sys
import subprocess
import winreg # pylint: disable=import-error
from os import environ
from pathlib import Path


Expand All @@ -10,10 +12,10 @@ def _options():
return parser.parse_args()


def _run_process(args):
def _run_process(args, env=None):
sys.stdout.flush()
try:
process = subprocess.Popen(args)
process = subprocess.Popen(args, env=env)
exit_code = process.wait()
if exit_code != 0:
raise RuntimeError("Wait failed with exit code {}".format(exit_code))
Expand All @@ -23,24 +25,41 @@ def _run_process(args):
sys.stdout.flush()


def _read_sys_env(environement_variable_name):
key = winreg.CreateKey(
winreg.HKEY_LOCAL_MACHINE,
r"System\CurrentControlSet\Control\Session Manager\Environment",
)
return winreg.QueryValueEx(key, environement_variable_name)[0]


def _test(root):
environment = environ.copy()
sys_path_key = "PATH"
sys_path_value = _read_sys_env(sys_path_key)
environment[sys_path_key] = sys_path_value
_run_process(
("python", "-m", "pytest", str(root), "-c", str(root / "pytest.ini"),),
env=environment,
)


def _install_pip_dependencies():
print("Installing python test requirements", flush=True)
_run_process(
(
"echo",
"TODO: ",
"python",
"-m",
"pytest",
str(root),
"-c",
str(root / "pytest.ini"),
"pip",
"install",
"--requirement",
"continuous-integration/python-requirements/test.txt",
)
)


def _main():
options = _options()

_install_pip_dependencies()
_test(options.root)


Expand Down
10 changes: 10 additions & 0 deletions test/test_samples.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
import platform

import pytest


@pytest.mark.skipif(
platform.system() == "Windows",
reason=r"python: can't open file 'D:\a\samples\sample_capture_from_file.py': [Errno 2] No such file or directory",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you can make an issue to investigate this further later.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#82

Copy link
Contributor

@nedrebo nedrebo Jul 20, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is hard to find the link between this code and #82.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this is already addressed in #85. No need to do anything with this now, but in general, it is a good rule to never leave loose ends around in master. Often they are not going to be cleaned up right away when things are still fresh in memory.

)
def test_capture_from_file(sample_data_file):
pytest.helpers.run_sample(
name="capture_from_file", working_directory=sample_data_file.parent
)


@pytest.mark.skipif(
platform.system() == "Windows",
reason=r"python: can't open file 'D:\a\samples\sample_print_version_info.py': [Errno 2] No such file or directory",
)
def test_print_version_info():
pytest.helpers.run_sample(name="print_version_info")