diff --git a/0.0.0/world_with_chest/launchConfig.zon b/0.0.0/world_with_chest/launchConfig.zon new file mode 100644 index 0000000..4551a9d --- /dev/null +++ b/0.0.0/world_with_chest/launchConfig.zon @@ -0,0 +1,5 @@ +.{ + .cubyzDir = ".", + .autoEnterWorld = "0.0.0", + .headlessServer = true, +} diff --git a/0.0.0/world_with_chest/run.py b/0.0.0/world_with_chest/run.py new file mode 100644 index 0000000..3ed40d0 --- /dev/null +++ b/0.0.0/world_with_chest/run.py @@ -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') +file.extractall('cubyzDir/saves') + +shutil.copy('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) diff --git a/0.0.0/world_with_chest/world.tar.gz b/0.0.0/world_with_chest/world.tar.gz new file mode 100644 index 0000000..f9a8f29 Binary files /dev/null and b/0.0.0/world_with_chest/world.tar.gz differ diff --git a/test.py b/test.py new file mode 100644 index 0000000..b7c197f --- /dev/null +++ b/test.py @@ -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) + p.wait() + if(p.returncode != 0): + print('Failure') + exitCode = 1 + else: + print('Success') + +exit(exitCode) +