building app test-run mechanism

This commit is contained in:
Eric 2023-06-05 17:09:24 -07:00
parent e8e54dfa91
commit a8f168a7e8
No known key found for this signature in database
GPG Key ID: 89C93F0F8D6D5A98
3 changed files with 76 additions and 47 deletions

View File

@ -4080,18 +4080,18 @@
"build/prefab/full/linux_x86_64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/b2/55/64d847b58c501c80b4ea53678e9a",
"build/prefab/full/linux_x86_64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/9f/37/b4553f9f9fda9fb07d7f3f3ab2f6",
"build/prefab/full/linux_x86_64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/cf/b4/d955fed8589fd59e0f15e69ab568",
"build/prefab/full/mac_arm64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/4a/05/10cc30b0ded557d9286e2e26d486",
"build/prefab/full/mac_arm64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/dc/44/de081983fef203f8ffcd0b553e19",
"build/prefab/full/mac_arm64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/b1/2f/33ad58bdcbcb2ac5de570b7b86d4",
"build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/18/22/57ccb81d1b96110eff004a1656d5",
"build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/d6/c7/623425ad23b0e49a0cd6ce28fddb",
"build/prefab/full/mac_arm64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/d4/50/fc305556a2926c5c69004b49a09a",
"build/prefab/full/mac_x86_64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/90/32/4e95ddbb7611ae96df47a3dd173a",
"build/prefab/full/mac_x86_64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/be/be/51940a5b107d09f206fb3989c395",
"build/prefab/full/mac_x86_64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/bc/5d/513cbfa9287f138912cb73f61783",
"build/prefab/full/mac_x86_64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/b7/19/5973c9eb86ff711c7856651f5229",
"build/prefab/full/mac_x86_64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/12/57/859c0ebc30c2467eaecbd768c66a",
"build/prefab/full/mac_x86_64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/e3/71/cd19381bd0a9c81f112dd90868ae",
"build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "https://files.ballistica.net/cache/ba1/a5/9b/ecf8dae5f555fd38551c8884927c",
"build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "https://files.ballistica.net/cache/ba1/9c/6d/fa923da9bb9609523f9ae37ebd56",
"build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "https://files.ballistica.net/cache/ba1/9e/34/83a809f6d12b058ba5a45fd0eb00",
"build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "https://files.ballistica.net/cache/ba1/ff/09/3fcb74ff33a3a711acd4e9b75e13",
"build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "https://files.ballistica.net/cache/ba1/47/22/419a37ddd3b768ca0dd51705bbde",
"build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "https://files.ballistica.net/cache/ba1/eb/13/cc6b88e80228c3fc223445e21e89",
"build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "https://files.ballistica.net/cache/ba1/a4/f2/5d5be9f42dd24ae9b892601ad683",
"build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "https://files.ballistica.net/cache/ba1/5e/24/95785e5bedfd942bf210b3865148",
"build/prefab/lib/linux_arm64_gui/debug/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/98/32/43c61f1e11520f764158cf0e76d2",
"build/prefab/lib/linux_arm64_gui/release/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/ca/65/cba463f21a8f76c5bbfe27cae124",
"build/prefab/lib/linux_arm64_server/debug/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/73/20/119211f1700bb5a410cedf4e76f2",
@ -4108,14 +4108,14 @@
"build/prefab/lib/mac_x86_64_gui/release/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/90/9b/94f733c3a48691e02240e04dc792",
"build/prefab/lib/mac_x86_64_server/debug/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/2e/c7/873af48627997b6fab4b2c4ba6bc",
"build/prefab/lib/mac_x86_64_server/release/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/3a/94/4780fada10f0fc3f43a54f29c86f",
"build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.lib": "https://files.ballistica.net/cache/ba1/d9/cf/2f90c4210742224541437ae51521",
"build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.pdb": "https://files.ballistica.net/cache/ba1/1d/10/0f1585c47316e8a2015c6e1efb71",
"build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.lib": "https://files.ballistica.net/cache/ba1/f1/41/71edf4fef97a89aca00078ae668a",
"build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.pdb": "https://files.ballistica.net/cache/ba1/60/08/ef5554bc3e3af5e8e7daa7cbe4ff",
"build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.lib": "https://files.ballistica.net/cache/ba1/7c/5f/843eac9fe5db8541b0a1875d89cd",
"build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.pdb": "https://files.ballistica.net/cache/ba1/e3/db/2eb585cae51558230c7511768b56",
"build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.lib": "https://files.ballistica.net/cache/ba1/86/49/675ce12e49e33bdd2327850eac28",
"build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.pdb": "https://files.ballistica.net/cache/ba1/2d/17/833dcfd99307a446e607bf8d5c10",
"build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.lib": "https://files.ballistica.net/cache/ba1/71/8c/540e4c3efe754041b26a2947b14a",
"build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.pdb": "https://files.ballistica.net/cache/ba1/f1/86/454aac22681002628615187d28f6",
"build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.lib": "https://files.ballistica.net/cache/ba1/fa/da/f218c6e71f7c56c47ddf7ba91ef8",
"build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.pdb": "https://files.ballistica.net/cache/ba1/6c/26/3ca064faa1000fb69e41eba24425",
"build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.lib": "https://files.ballistica.net/cache/ba1/75/7a/4122bb4143cb68872b5b3dcebe49",
"build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.pdb": "https://files.ballistica.net/cache/ba1/97/20/6ec2421f83b1e9a1ca937e36a588",
"build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.lib": "https://files.ballistica.net/cache/ba1/ad/e9/b86c0a5a916f4ec3c2e586f0604f",
"build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.pdb": "https://files.ballistica.net/cache/ba1/d1/a8/c5ccf4c0bb5b504c5e32adaa98a3",
"src/assets/ba_data/python/babase/_mgen/__init__.py": "https://files.ballistica.net/cache/ba1/52/c6/c11130af7b10d6c0321add5518fa",
"src/assets/ba_data/python/babase/_mgen/enums.py": "https://files.ballistica.net/cache/ba1/38/c3/1dedd5e74f2508efc5974c8815a1",
"src/ballistica/base/mgen/pyembed/binding_base.inc": "https://files.ballistica.net/cache/ba1/4e/07/87dd93e7ef29b8b78d0b4791d6f8",

View File

@ -4,39 +4,19 @@
from __future__ import annotations
from typing import TYPE_CHECKING
if TYPE_CHECKING:
pass
import pytest
from batools import testrun
@pytest.mark.skipif(
testrun.test_runs_disabled(),
reason='Test app runs disabled here.',
)
def test_babase_imports() -> None:
"""Testing."""
import subprocess
import platform
# Currently skipping this on Windows, as we can't assemble a
# complete build there currently (can only compile binaries).
if platform.system() == 'Windows':
return
# Put together the headless binary we use for testing.
subprocess.run(['make', 'cmake-server-build'], check=True)
builddir = 'build/cmake/server-debug/dist'
# Make sure we can cleanly import both our Python package and binary
# module by themselves.
subprocess.run(
f'PYTHONPATH={builddir}/ba_data/python'
f' {builddir}/ballisticakit_headless -c "import babase"',
check=True,
shell=True,
)
subprocess.run(
f'PYTHONPATH={builddir}/ba_data/python'
f' {builddir}/ballisticakit_headless -c "import _babase"',
check=True,
shell=True,
)
# Make sure our package and binary module can be cleanly imported by
# themselves.
testrun.run_command('import babase')
testrun.run_command('import _babase')

49
tools/batools/testrun.py Executable file
View File

@ -0,0 +1,49 @@
# Released under the MIT License. See LICENSE for details.
#
"""Utils for test runs of the app."""
from __future__ import annotations
from typing import TYPE_CHECKING
import platform
import subprocess
import os
if TYPE_CHECKING:
pass
def test_runs_disabled() -> bool:
"""Are test runs disabled on the current platform?"""
# Currently skipping this on Windows, as we aren't able to assemble
# complete build there without WSL.
if platform.system() == 'Windows':
return True
return False
def get_binary() -> str:
"""Return a path to a server build binary, building it if need be."""
subprocess.run(['make', 'cmake-server-build'], check=True)
builddir = 'build/cmake/server-debug/dist'
binpath = os.path.join(builddir, 'ballisticakit_headless')
assert os.path.isfile(binpath)
return binpath
def run_command(cmd: str) -> None:
"""Run a cmd with a built bin and PYTHONPATH set to its scripts dir."""
binpath = get_binary()
bindir = os.path.dirname(binpath)
cmdargs = [binpath, '--command', cmd]
print(f'Running command: {cmdargs}...')
subprocess.run(
cmdargs,
env=dict(os.environ, PYTHONPATH=f'{bindir}/ba_data/python'),
check=True,
)