Skip to content
Open
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
5 changes: 5 additions & 0 deletions 0.0.0/world_with_chest/launchConfig.zon
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.{
.cubyzDir = ".",
.autoEnterWorld = "0.0.0",
.headlessServer = true,
}
46 changes: 46 additions & 0 deletions 0.0.0/world_with_chest/run.py
Copy link
Copy Markdown

@Argmaster Argmaster Dec 25, 2025

Choose a reason for hiding this comment

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

For now, I would suggest directory structure <test_case>/<assets_version> instead, so you can run same test case on multiple versions of assets and change the assets without moving the test case, it creates noise.

I have further thoughts on version being in path, but lets leave it for now.

Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import os
from pathlib import Path
import shutil
import subprocess
import sys
import tarfile

if(len(sys.argv) != 3):
print('Usage: python test.py path/to/Cubyz/executable path/to/Cubyz/assets')
exit(1)

exe = sys.argv[1]
assets = sys.argv[2]

Path('cubyzDir').mkdir()
Path('cubyzDir/saves').mkdir()
Path('cubyzDir/assets').symlink_to(Path(assets))

file = tarfile.open('world.tar.gz')
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Python files can be ran from any place in file system. Use relative path:

Suggested change
file = tarfile.open('world.tar.gz')
file = tarfile.open(Path(__file__).parent / 'world.tar.gz')

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The intention here is that only the framework runs these, which can control the working directory.

file.extractall('cubyzDir/saves')

shutil.copy('launchConfig.zon', 'cubyzDir')
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
shutil.copy('launchConfig.zon', 'cubyzDir')
shutil.copy(Path(__file__).parent / 'launchConfig.zon', 'cubyzDir')


returnCode = 0

p = subprocess.Popen([exe], cwd='cubyzDir', stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
while True:
line = p.stderr.readline().strip()
if not line:
break
if line.startswith('[error]:'):
print(line)
returnCode = 1
if line == '[info]: Finished LOD update.':
p.terminate()
print("terminating")
break
p.wait()

for line in p.stdout.read():
print(line)

Path('cubyzDir/assets').unlink()
shutil.rmtree('cubyzDir')

exit(returnCode)
Binary file added 0.0.0/world_with_chest/world.tar.gz
Binary file not shown.
30 changes: 30 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import os
import subprocess
import sys

if(len(sys.argv) != 3):
print('Usage: python test.py path/to/Cubyz/executable path/to/Cubyz/assets')
exit(1)

exe = os.path.abspath(sys.argv[1])
print('Running tests with Cubyz executable: ' + exe)
assets = os.path.abspath(sys.argv[2])
print('Running tests with Cubyz assets: ' + assets)

exitCode = 0

for root, dirs, files in os.walk('.'):
for filename in files:
if not filename == 'run.py': continue
path = os.path.join(root, filename)
print('Running test: ' + path)
p = subprocess.Popen(['python3', filename, exe, assets], cwd=root)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
p = subprocess.Popen(['python3', filename, exe, assets], cwd=root)
p = subprocess.Popen([sys.executable, filename, exe, assets], cwd=root)

p.wait()
if(p.returncode != 0):
print('Failure')
exitCode = 1
else:
print('Success')

exit(exitCode)