Context
Historically, Codexis test code has used a mix of approaches for creating temporary files and directories, including direct calls to File.mkdir_p!, File.write!, and hardcoded paths like tmp, tmp_test, or test/fixtures. This has led to:
- Permission errors on CI and some developer machines
- Inconsistent or incomplete cleanup of temp files/dirs
- Tests that are not portable across environments
- Occasional pollution of the project root or persistent test data directories
Decision
All test code in Codexis must use the Briefly library (or a project-standard wrapper around Briefly) for creating and managing temporary files and directories.
- No test may write to the project root,
tmp, ortest/fixturesdirectly. - All temp dirs/files must be created with
Briefly.create/1(or a shared fixture that uses Briefly). - Persistent test data (e.g.,
test/fixtures) must be read-only and never written to or cleaned up by tests. - All test helpers/fixtures must be refactored to use Briefly for temp resources.
- Manual cleanup (
on_exitfor temp dirs/files) should be removed where Briefly is used, as Briefly handles cleanup automatically.
Consequences
- Positive:
- No more permission errors due to unwritable temp locations
- Automatic, reliable cleanup of all temp files/dirs after tests
- Tests are portable and robust across all environments (local, CI, sandboxed)
- Easier maintenance and clearer test setup/teardown
- Negative:
- Requires refactoring of existing test code and helpers
- Developers must learn and consistently use Briefly patterns