Files
dcr/docs/commands/dcr-test.md
Dexoron fd88e036ed feat: add cross-compilation support with --target flag
- Updated build and run commands to accept a --target option for specifying target platforms.
- Enhanced documentation to include cross-compilation usage and supported targets.
- Modified configuration to allow target-specific settings and toolchains.
- Introduced a new test command to run project tests with specified profiles and targets.
- Improved handling of target directories and output structure for different platforms.
- Added support for multiple targets in the configuration file.
- Implemented inheritance for workspace and dependencies based on target and profile.
2026-04-11 13:36:18 +08:00

1.2 KiB

dcr test

Runs the project's test suite.

Usage

dcr test
dcr test --release
dcr test --target linux
dcr test --init

What test does

  1. Builds the project with the specified profile/target.
  2. Compiles test files in tests/ (e.g., tests/test.c) into a test binary.
  3. Runs the test binary and parses output for PASS/SKIP/FAIL results.
  4. Reports summary with colored output.

Test Structure

DCR uses a simple test framework:

  • Header: tests/dcr_test.h (generated by dcr test --init)
  • Test file: tests/test.c (template generated by dcr test --init)
  • Macros: TEST(name), TEST_CASE(name), EXPECT(condition), SKIP(reason)
  • Output: [PASS] test_name, [FAIL] test_name, or [SKIP] test_name

Config values used

  • package.name
  • build.compiler, build.language, build.standard
  • build.cflags, build.ldflags
  • build.debug / build.release
  • build.targets (if specified)

Notes

  • Test binary is linked with the main project (for lib projects) or standalone.
  • --init creates tests/dcr_test.h and tests/test.c if missing.
  • Tests run in release mode by default for performance.
  • Custom test logic can be added by editing tests/test.c.
  • Fails if no tests/test.c exists (run dcr test --init first).