t21704.nim 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. discard """
  2. matrix: "--hints:off"
  3. nimout: '''
  4. Found 2 tests to run.
  5. Found 3 benches to compile.
  6. --passC:-Wno-stringop-overflow --passL:-Wno-stringop-overflow
  7. --passC:-Wno-stringop-overflow --passL:-Wno-stringop-overflow
  8. --passC:-Wno-stringop-overflow --passL:-Wno-stringop-overflow
  9. '''
  10. """
  11. # bug #21704
  12. import std/strformat
  13. const testDesc: seq[string] = @[
  14. "tests/t_hash_sha256_vs_openssl.nim",
  15. "tests/t_cipher_chacha20.nim"
  16. ]
  17. const benchDesc = [
  18. "bench_sha256",
  19. "bench_hash_to_curve",
  20. "bench_ethereum_bls_signatures"
  21. ]
  22. proc setupTestCommand(flags, path: string): string =
  23. return "nim c -r " &
  24. flags &
  25. &" --nimcache:nimcache/{path} " & # Commenting this out also solves the issue
  26. path
  27. proc testBatch(commands: var string, flags, path: string) =
  28. commands &= setupTestCommand(flags, path) & '\n'
  29. proc setupBench(benchName: string): string =
  30. var runFlags = if false: " -r "
  31. else: " " # taking this branch is needed to trigger the bug
  32. echo runFlags # Somehow runflags isn't reset in corner cases
  33. runFlags &= " --passC:-Wno-stringop-overflow --passL:-Wno-stringop-overflow "
  34. echo runFlags
  35. return "nim c " &
  36. runFlags &
  37. &" benchmarks/{benchName}.nim"
  38. proc buildBenchBatch(commands: var string, benchName: string) =
  39. let command = setupBench(benchName)
  40. commands &= command & '\n'
  41. proc addTestSet(cmdFile: var string) =
  42. echo "Found " & $testDesc.len & " tests to run."
  43. for path in testDesc:
  44. var flags = "" # This is important
  45. cmdFile.testBatch(flags, path)
  46. proc addBenchSet(cmdFile: var string) =
  47. echo "Found " & $benchDesc.len & " benches to compile."
  48. for bd in benchDesc:
  49. cmdFile.buildBenchBatch(bd)
  50. proc task_bug() =
  51. var cmdFile: string
  52. cmdFile.addTestSet() # Comment this out and there is no bug
  53. cmdFile.addBenchSet()
  54. static: task_bug()