Skip to content

Conversation

@IntegratedQuantum
Copy link
Member

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.

Copy link

@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.

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

file = tarfile.open('world.tar.gz')

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
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 = tarfile.open('world.tar.gz')
file.extractall('cubyzDir/saves')

shutil.copy('launchConfig.zon', 'cubyzDir')

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')

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)

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)

Copy link

@Argmaster Argmaster left a 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.

@IntegratedQuantum
Copy link
Member Author

Lets merge this and come back to it after 0.1.0 release.

No, I think we should discuss this first, to avoid having to rewrite a bunch of code after other contributors start making PRs here.

@IntegratedQuantum
Copy link
Member Author

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.

Well I have not used python in more than small scripts, so please enlighten me about how this should be done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants