-
Notifications
You must be signed in to change notification settings - Fork 1
Add a first prototype that loads a world using headless and checks for error logs #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| .{ | ||
| .cubyzDir = ".", | ||
| .autoEnterWorld = "0.0.0", | ||
| .headlessServer = true, | ||
| } |
| 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') | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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') | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| 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) | ||||||
| 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) | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| p.wait() | ||||||
| if(p.returncode != 0): | ||||||
| print('Failure') | ||||||
| exitCode = 1 | ||||||
| else: | ||||||
| print('Success') | ||||||
|
|
||||||
| exit(exitCode) | ||||||
|
|
||||||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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.