Skip to content

Commit 6b42dc8

Browse files
committed
Move around some tests
1 parent 240f7f2 commit 6b42dc8

File tree

11 files changed

+97
-6
lines changed

11 files changed

+97
-6
lines changed

.github/workflows/pipeline.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,7 @@ jobs:
5050
with:
5151
compiler: g++-14.2.0
5252
- name: Build test binaries
53-
run: g++ ./tests/cpp/app.cpp -Wall -o ./tests/app.exe
54-
- name: Upload exe
55-
uses: actions/upload-artifact@v4
56-
with:
57-
name: test_app
58-
path: ./tests/app.exe
53+
run: g++ ./tests/programs/src/app.cpp -Wall -o ./tests/programs/app.exe
5954
- name: Run unit tests
6055
run: uv run pytest ./tests
6156
build:

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,6 @@ mods
1313
docs/api/*.rst
1414
# Explicitly keep this file as we aren't generating it automatically.
1515
!docs/api/index.rst
16+
17+
# Generated binaries for testing
18+
*.exe

tests/integration/readme.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
This is a collection of tests which will run on real programs.
2+
All the executables are built on the CI.

tests/integration/test_app.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import pymhf
2+
3+
4+
def test_app():
5+
pass

tests/test_mods/app_test_mod.py

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# /// script
2+
# dependencies = ["pymhf[gui]==0.1.11"]
3+
#
4+
# [tool.uv.sources]
5+
# pymhf = { index = "pypi_test" }
6+
#
7+
# [[tool.uv.index]]
8+
# name = "pypi_test"
9+
# url = "https://test.pypi.org/simple/"
10+
# explicit = true
11+
#
12+
# [tool.pymhf]
13+
# exe = "NMS.exe"
14+
# steam_gameid = 275850
15+
# start_paused = false
16+
#
17+
# [tool.pymhf.gui]
18+
# always_on_top = true
19+
#
20+
# [tool.pymhf.logging]
21+
# log_dir = "."
22+
# log_level = "info"
23+
# window_name_override = "NMS audio thing"
24+
# ///
25+
from __future__ import annotations
26+
27+
import ctypes
28+
import ctypes.wintypes as wintypes
29+
import logging
30+
from dataclasses import dataclass
31+
from typing import Annotated, Optional, overload
32+
33+
import pymhf.core._internal as _internal
34+
from pymhf import Mod
35+
from pymhf.core.hooking import (
36+
Structure,
37+
disable,
38+
function_hook,
39+
get_caller,
40+
on_key_pressed,
41+
static_function_hook,
42+
)
43+
from pymhf.core.memutils import get_addressof, map_struct
44+
from pymhf.core.mod_loader import ModState
45+
from pymhf.core.utils import set_main_window_active
46+
from pymhf.gui.decorators import BOOLEAN, STRING, gui_button, gui_combobox
47+
from pymhf.utils.partial_struct import Field, partial_struct
48+
49+
logger = logging.getLogger("AudioNames")
50+
51+
FUNC_NAME = "?PostEvent@SoundEngine@AK@@YAII_KIP6AXW4AkCallbackType@@PEAUAkCallbackInfo@@@ZPEAXIPEAUAkExternalSourceInfo@@I@Z"
52+
REGISTER_FUNC = "?RegisterGameObj@SoundEngine@AK@@YA?AW4AKRESULT@@_KPEBD@Z"
53+
54+
55+
@static_function_hook(exported_name="multiply")
56+
def multiply(a: ctypes.c_int32, b: ctypes.c_int64) -> ctypes.c_int64:
57+
...
58+
59+
60+
@dataclass
61+
class AudioState(ModState):
62+
event_id: int = 0
63+
obj_id: int = 0
64+
play_sounds: bool = True
65+
log_sounds: bool = True
66+
67+
68+
class AppMod(Mod):
69+
__author__ = "monkeyman192"
70+
__description__ = "Log (almost) all audio events when they happen"
71+
__version__ = "0.1"
72+
73+
state = AudioState()
74+
75+
def __init__(self):
76+
super().__init__()
77+
self.audio_manager = None
78+
self.count = 0
79+
80+
@multiply.before
81+
def before_multiply(self, a: int, b: int):
82+
print(a, b)
83+
84+
@multiply.after
85+
def after_play_attenuated(self, a: int, b: int, _result_: int):
86+
print(a, b, _result_)

0 commit comments

Comments
 (0)