test.mts 840 B

12345678910111213141516171819202122232425
  1. #!/usr/bin/env zx
  2. import 'zx/globals';
  3. import {
  4. getToolchainArgument,
  5. parseCliArguments,
  6. workingDirectory,
  7. } from '../helpers/utils.mts';
  8. // Extract the crate directory from the command-line arguments.
  9. const { manifestPath, args } = parseCliArguments();
  10. // Configure additional arguments here, e.g.:
  11. // ['--arg1', '--arg2', ...args]
  12. const testArgs = args;
  13. const toolchain = getToolchainArgument('test');
  14. const hasSolfmt = await which('solfmt', { nothrow: true });
  15. const sbfOutDir = path.join(workingDirectory, 'target', 'deploy');
  16. // Run the tests.
  17. if (hasSolfmt) {
  18. await $`SBF_OUT_DIR=${sbfOutDir} cargo ${toolchain} test --all-features --manifest-path ${manifestPath} ${testArgs} >&1 | solfmt`;
  19. } else {
  20. await $`SBF_OUT_DIR=${sbfOutDir} cargo ${toolchain} test --all-features --manifest-path ${manifestPath} ${testArgs}`;
  21. }