Skip to content

Commit

Permalink
add test-fixture checks for binaries
Browse files Browse the repository at this point in the history
  • Loading branch information
supervacuus committed Nov 11, 2024
1 parent 6e64ba3 commit a3bbde0
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions scripts/bump-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ perl -pi -e "s/^#define SENTRY_SDK_VERSION.*/#define SENTRY_SDK_VERSION \"${NEW_
perl -pi -e "s/\"version\": \"[^\"]+\"/\"version\": \"${NEW_VERSION}\"/" tests/assertions.py
perl -pi -e "s/sentry.native\/[^\"]+\"/sentry.native\/${NEW_VERSION}\"/" tests/test_integration_http.py
perl -pi -e "s/^versionName\=.*/versionName\=${NEW_VERSION}/" ndk/gradle.properties
perl -pi -e "s/^sentry_version \=.*/sentry_version \= \"${NEW_VERSION}\"/" tests/win_utils.py
10 changes: 10 additions & 0 deletions tests/cmake.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@
import shutil
import subprocess
import sys
import platform
from pathlib import Path

import pytest

from tests.win_utils import check_binary_version


class CMake:
def __init__(self, factory):
Expand Down Expand Up @@ -204,6 +208,12 @@ def cmake(cwd, targets, options=None):
except subprocess.CalledProcessError:
raise pytest.fail.Exception("cmake build failed") from None

# check if the DLL and EXE artifacts contain version-information
if platform.system() == "Windows":
check_binary_version(Path(cwd) / "sentry.dll")
check_binary_version(Path(cwd) / "crashpad_wer.dll")
check_binary_version(Path(cwd) / "crashpad_handler.exe")

if "code-checker" in os.environ.get("RUN_ANALYZER", ""):
# For whatever reason, the compilation summary contains duplicate entries,
# one with the correct absolute path, and the other one just with the basename,
Expand Down
1 change: 1 addition & 0 deletions tests/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ pytest-httpserver==1.0.10
msgpack==1.0.8
pytest-xdist==3.5.0
clang-format==19.1.3
pywin32==308; sys_platform == "win32"
19 changes: 19 additions & 0 deletions tests/win_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import pathlib
import win32api

sentry_version = "0.7.12"


def check_binary_version(binary_path: pathlib.Path):
if not binary_path.exists():
return

info = win32api.GetFileVersionInfo(str(binary_path), "\\")
ms = info["FileVersionMS"]
ls = info["FileVersionLS"]
file_version = (ms >> 16, ms & 0xFFFF, ls >> 16, ls & 0xFFFF)
file_version = f"{file_version[0]}.{file_version[1]}.{file_version[2]}"
if sentry_version != file_version:
raise RuntimeError(
f"Binary {binary_path.parts[-1]} has a different version ({file_version}) than expected ({sentry_version})."
)

0 comments on commit a3bbde0

Please sign in to comment.