-
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?
Add a first prototype that loads a world using headless and checks for error logs #1
Conversation
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.
| 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 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:
| file = tarfile.open('world.tar.gz') | |
| file = tarfile.open(Path(__file__).parent / 'world.tar.gz') |
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.
The intention here is that only the framework runs these, which can control the working directory.
| file = tarfile.open('world.tar.gz') | ||
| file.extractall('cubyzDir/saves') | ||
|
|
||
| shutil.copy('launchConfig.zon', 'cubyzDir') |
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.
| shutil.copy('launchConfig.zon', 'cubyzDir') | |
| shutil.copy(Path(__file__).parent / 'launchConfig.zon', 'cubyzDir') |
| 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 comment
The reason will be displayed to describe this comment to others. Learn more.
| p = subprocess.Popen(['python3', filename, exe, assets], cwd=root) | |
| p = subprocess.Popen([sys.executable, filename, exe, assets], cwd=root) |
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.
Lets merge this and come back to it after 0.1.0 release.
I believe that you have checked it runs on yours machine, but is surely doesn't run on mine (windows)
Running tests with Cubyz executable: C:\Users\argma\dev\Cubyz-testing\Cubyz\zig-out\bin\Cubyz.exe
Running tests with Cubyz assets: C:\Users\argma\dev\Cubyz-testing\Cubyz\assets
Running test: .\0.0.0\world_with_chest\run.py
Traceback (most recent call last):
File "C:\Users\argma\dev\Cubyz-testing\0.0.0\world_with_chest\run.py", line 12, in <module>
Path('cubyzDir').mkdir()
File "C:\Users\argma\python\python3122\Lib\pathlib.py", line 1311, in mkdir
os.mkdir(self, mode)
FileExistsError: [WinError 183] Cannot create a file when that file already exists: 'cubyzDir'
From Python perspective this is a complete mess of a project structure, so If you don't want to bang your head against every Python ecosystem wall and fall ino every trap, I would suggest revisiting that design w/o intention to reinvent how to write tests in Python.
No, I think we should discuss this first, to avoid having to rewrite a bunch of code after other contributors start making PRs here. |
Well I have not used python in more than small scripts, so please enlighten me about how this should be done. |
The rough idea is to have one folder for each test case, with a world file, script and a launchConfig.
When running the test, the world is unpacked and stored in a subfolder, the launchConfig is also copied there and a symlink to the cubyz assets is created. In the future if we need more options (settings, custom assets, ...), then these can also be put here instead of having a complex scenario description object as proposed in https://github.com/Argmaster/Circlez/, this would also make it easier to reuse the configuration outside of the framework.
All the setup and cleanup code clearly shows that we actually should have some kind of framework library that handles this automatically, however this outside of my python abilities and can probably be added later.
For the world I chose a freshly created chest with items inside, so that the game executes the LOD regeneration step. This also gives us a way to detect when the server has finished the startup code.