Unit tests: create one top-level temporary directory #12574

issue laanwj opened this issue on March 1, 2018
  1. laanwj commented at 11:29 AM on March 1, 2018: member

    Currently, every unit test that needs a temporary directory creates a directory directly under the system tmp path, /tmp/0df0-cbb9-e3f5-5753 and such. This gets cluttered really quickly, especially if tests fail to clean up. If a directory is left behind it can be tricky to find out which test is the culprit.

    I would prefer creating one temporary directory at start of the entire framework, then creating directories under this with the name of the test and optional iteration number. E.g. /tmp/0df0-cbb9-e3f5-5753/dbwrapper_1. This makes it clear if tests leave behind junk, and facilitates cleanup.

    Two different mechanisms are used currently for generating temporary directories:

    • pathTemp = fs::temp_directory_path() / strprintf("test_bitcoin_%lu_%i", (unsigned long)GetTime(), (int)(InsecureRandRange(100000))) ()
    • fs::temp_directory_path() / fs::unique_path()

    This would also be unified, then.

  2. laanwj added the label Tests on Mar 1, 2018
  3. laanwj added the label good first issue on Mar 1, 2018
  4. chrislennon cross-referenced this on Mar 2, 2018 from issue [WIP] Unit test sub-directories by chrislennon
  5. winder cross-referenced this on May 2, 2018 from issue Use common getPath method to create temp directory in tests. by winder
  6. MarcoFalke referenced this in commit d3dae3ddf9 on Jul 12, 2018
  7. MarcoFalke removed the label good first issue on Jul 12, 2018
  8. MarcoFalke added the label good first issue on Jul 12, 2018
  9. MarcoFalke commented at 11:53 AM on July 12, 2018: member

    Closing for now. Let me know if this still an issue.

  10. MarcoFalke closed this on Jul 12, 2018

  11. HashUnlimited cross-referenced this on Sep 11, 2018 from issue Use common getPath method to create temp directory in tests. by HashUnlimited
  12. PastaPastaPasta referenced this in commit 6372283967 on Dec 16, 2020
  13. PastaPastaPasta referenced this in commit 5c7c9a00da on Dec 18, 2020
  14. PastaPastaPasta referenced this in commit 2a69d81fae on Dec 18, 2020
  15. bitcoin locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-05-20 06:55 UTC