This guide explains how to run and write tests for the project.
To ensure that the code remains stable and correct, we maintain a suite of unit tests, integration tests, and end-to-end tests (where applicable). Contributors should run the test suite before submitting changes.
Most tests can be run with:
cargo test
Add additional flags if needed:
cargo test --features integration
Depending on the crate, you can also specify which package to test:
cargo test -p wonopcode-core
Some tests rely on environment variables or the config schema. Please see Configuration Schema for details.
• If you have certain environment variables defined (e.g., LOG_LEVEL="debug"), it may affect test verbosity.
• Permissions can also be toggled via config in local project settings, which can influence tests.
Here are a few common issues you might encounter:
-
Tests failing in CI but passing locally
- Check for environment differences (e.g. missing environment variables, different cargo or rustc versions, or OS-level dependencies).
- Some tests might rely on external services or tools that are not available in CI.
-
Networking tests timing out
- Ensure that
permissions.networkis enabled in either your config or environment when running. - Verify your internet connection or local DNS settings.
- Ensure that
-
Permission errors
- If sandbox is incorrectly configured, file read/write tests may fail.
- See the "permissions" setting in Configuration Schema and confirm the relevant flags.
-
Docker-based testing issues
- Check Docker version and resources if the tests are containerized.
- Some directories may be mapped incorrectly if sandbox paths or volumes mismatch.
-
Feature flag confusion
- For crates that have multiple optional features, ensure you enable them when required or see if any feature is conflicting with test assumptions.
• Development Setup for environment configuration. • Contributing Guide for general guidelines on pull requests and coding standards.
End of Testing Guide