Skip to content
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

test: standardize unity project setup #99

Merged
merged 14 commits into from
Jan 14, 2024
Merged

test: standardize unity project setup #99

merged 14 commits into from
Jan 14, 2024

Conversation

ComradeVanti
Copy link
Collaborator

@ComradeVanti ComradeVanti commented Jan 9, 2024

This PR standardizes Unity project setup procedures for tests. This was previously done using the functions inside mock-work-dir. The PR changes and expands these functions in a few ways.

Changes

The new system always sets up the same folder structure which looks like this:

[Os Temp folder]
| test-openupm-cli
   | .upmconfig.toml
   | Project
      | ProjectSettings
         | EditorVersion.txt
      | Packages
         | manifest.json

This is equivalent to the old test-project structure except for the addition of a .upmconfig.toml. The test-openupm-cli folder now serves as a mocked user-home, which is why the config is stored there. Accordingly, for the duration of the tests the HOME environment variable will be set to the path of test-openupm-cli. The content of the .upmconfig.toml is configurable for different tests.

Common utility functions such as, resetting the folder between tests, querying the content of the project manifest or getting the path to the project directory have also been standardized.

In order to prevent needing to override cwd for each tests, process.cwd() is mocked to be inside test-openupm-cli/Project.

Reason

This standardization will future proof for three things which may be done in the future:

  • Allow easier implementation of configuration extensions for mock projects.
  • Use mock-fs or a similar library in order to run tests off the real file-system. This will allow to more easily parallel tests.
  • Prepare for a similar setup to be implemented for Unity package folders, in case OpenUpm also adds functionality for working with packages directly (init, publish or similar)

@favoyang favoyang merged commit 432d923 into openupm:master Jan 14, 2024
2 checks passed
@ComradeVanti ComradeVanti deleted the test-setup branch January 14, 2024 12:40
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