implemented artifact manager for total war pharaoh, also fixed a bug where the harness was nested two folders deep, making it invisible to markbench

This commit is contained in:
Arty Blue
2024-09-27 16:13:58 -07:00
parent 1171cc5d49
commit b31c5a6070
3 changed files with 63 additions and 0 deletions

View File

@@ -23,6 +23,7 @@ from harness_utils.output import (
)
from harness_utils.steam import get_app_install_location
from harness_utils.keras_service import KerasService
from harness_utils.artifacts import ArtifactManager, ArtifactType
SCRIPT_DIR = Path(__file__).resolve().parent
LOG_DIR = SCRIPT_DIR.joinpath("run")
@@ -78,8 +79,12 @@ def skip_logo_screens() -> None:
def run_benchmark(keras_service):
"""Starts the benchmark"""
cfg = f"{CONFIG_LOCATION}\\{CONFIG_FILENAME}"
start_game()
setup_start_time = time.time()
am = ArtifactManager(LOG_DIR)
time.sleep(5)
result = keras_service.look_for_word("warning", attempts=10, interval=5)
@@ -101,6 +106,60 @@ def run_benchmark(keras_service):
time.sleep(0.2)
gui.mouseUp()
if keras_service.wait_for_word(word="brightness", timeout=30, interval=1) is None:
logging.info("Did not find the main menu. Did Keras click correctly?")
sys.exit(1)
am.take_screenshot("main.png", ArtifactType.CONFIG_IMAGE, "screenshot of main settings menu")
time.sleep(0.5)
result = keras_service.look_for_word("advanced", attempts=10, interval=1)
if not result:
logging.info("Did not find the advanced options menu. Did the game navigate to options correctly?")
sys.exit(1)
gui.moveTo(result["x"], result["y"])
time.sleep(0.2)
gui.mouseDown()
time.sleep(0.2)
gui.mouseUp()
if keras_service.wait_for_word(word="water", timeout=30, interval=1) is None:
logging.info("Did not find the keyword 'water' in the menu. Did Keras navigate to the advanced menu correctly?")
sys.exit(1)
am.take_screenshot("advanced_1.png", ArtifactType.CONFIG_IMAGE, "first screenshot of advanced settings menu")
time.sleep(0.5)
result = keras_service.look_for_word("water", attempts=10, interval=1)
if not result:
logging.info("Did not find the keyword 'water' in the menu. Did Keras navigate to the advanced menu correctly?")
sys.exit(1)
gui.moveTo(result["x"], result["y"])
time.sleep(1)
for i in range(15):
gui.vscroll(-1)
time.sleep(0.1)
if keras_service.wait_for_word(word="heat", timeout=30, interval=1) is None:
logging.info("Did not find the keyword 'heat' in the menu. Did Keras scroll down the advanced menu far enough?")
sys.exit(1)
am.take_screenshot("advanced_2.png", ArtifactType.CONFIG_IMAGE, "second screenshot of advanced settings menu")
time.sleep(0.5)
for i in range(15):
gui.vscroll(-1)
time.sleep(0.1)
if keras_service.wait_for_word(word="bodies", timeout=30, interval=1) is None:
logging.info("Did not find the keyword 'bodies' in the menu. Did Keras scroll down the advanced menu far enough?")
sys.exit(1)
am.take_screenshot("advanced_3.png", ArtifactType.CONFIG_IMAGE, "third screenshot of advanced settings menu")
time.sleep(0.5)
result = keras_service.look_for_word("bench", attempts=10, interval=1)
if not result:
logging.info("Did not find the benchmark menu. Did the game skip the intros?")
@@ -136,6 +195,10 @@ def run_benchmark(keras_service):
# Wait 5 seconds for benchmark info
time.sleep(5)
am.take_screenshot("results.png", ArtifactType.RESULTS_IMAGE, "benchmark results")
time.sleep(0.5)
am.copy_file(Path(cfg), ArtifactType.CONFIG_TEXT, "preferences.script.txt")
# End the run
elapsed_test_time = round(test_end_time - test_start_time, 2)