[tests] improve tmpdir structure #10433

pull jnewbery wants to merge 1 commits into bitcoin:master from jnewbery:test_runner_tmpdir changing 2 files +27 −15
  1. jnewbery commented at 3:22 PM on May 19, 2017: member

    tl;dr:

    • temp directories now include the name of the test when run through the test_runner
    • passing a --tmpdirprefix to the test_runner allows test_runner to be called by cron/build jobs without risk of directory name collision

    ==================

    By default, the functional tests create their temp directories in the $TMPDIR as follows:

    $TMPDIR
       |
       -- test<rand_chars>
            |
            -- <port seed>
                |
                -- temp files
                -- ...
    

    a --tmpdir argument can be passed into the individual test case, which causes the temp directory to be written to:

    <specified --tmpdir>
       |
       -- <port seed>
            |
            -- temp files
            -- ...
    

    If --tmpdir is passed to the test_runner, then it gets passed down to the indivdual tests and the directory structure is:

    <specified --tmpdir>
       |
       -- <port seed 1>
            |
            -- temp files
            -- ...
       -- <port seed 2>
            |
            -- temp files
            -- ...
       -- ...
    
    

    There are a few problems:

    • the directory names give no indication of which test was being run, so it's difficult to quickly find the temp directory for an indvidual test if using the test_runner
    • if a --tmpdir directory is passed to the test_runner and there are already directories in that tmpdir with names that clash with the port seed, then tests will fail when they try to use that subdirectory. This can be a problem when running test_runner as a cron job or build job with a specified tmpdir. Test failures in one build will cause subsequent runs to fail because the subdirectories are not cleaned up
    • even if a tmpdir is specified, test_framework will still create an empty temp directory $TMPDIR/test<rand_chars> (this is because tempfile.mkdtemp(prefix="test") is called even when --tmpdir is used).

    This PR changes the temp dir structure so that:

    • if running the test directly:
      • if no --tmpdir is specified
        • temp directory is $TMPDIR/test<rand_chars> (as now, except without the <port seed> subdirectory)
      • if a --tmpdir is specified
        • temp directory is the specified tmpdir (as now, except without the <port seed> subdirectory)
    • if running through the test_runner
      • if no --tmpdirprefix is specified
        • temp directory is $TMPDIR/bitcoin_test_runner_<date>_<time>/<test_name>_portseed.
      • if a --tmpdirprefix is specified
        • temp directory is <tmpdirprefix>/bitcoin_test_runner_<date>_<time>/<test_name>_portseed.

    <tmpdirprefix> will be cleaned up by the test_runner if it is empty at the end of all tests (ie if all tests have cleaned up their own temp directories).

  2. [tests] improve tmpdir structure b040243cc3
  3. sdaftuar commented at 6:20 PM on May 19, 2017: member

    ACK, this looks great!

  4. fanquake added the label Tests on May 20, 2017
  5. laanwj commented at 7:03 AM on May 20, 2017: member

    Concept ACK

  6. kallewoof commented at 12:57 AM on May 22, 2017: member

    utACK b040243cc3dfd69f5a8b6e217d1a658d59b15809

  7. MarcoFalke commented at 7:00 AM on May 22, 2017: member

    utACK b040243cc3dfd69f5a8b6e217d1a658d59b15809

  8. MarcoFalke merged this on May 22, 2017
  9. MarcoFalke closed this on May 22, 2017

  10. MarcoFalke referenced this in commit 8e5725666b on May 22, 2017
  11. PastaPastaPasta referenced this in commit 32e0fc9660 on Jun 10, 2019
  12. PastaPastaPasta referenced this in commit 0cc94acf11 on Jun 11, 2019
  13. PastaPastaPasta referenced this in commit 52a485b5c8 on Jun 11, 2019
  14. PastaPastaPasta referenced this in commit 12bf4d40bf on Jun 15, 2019
  15. PastaPastaPasta referenced this in commit ea8d37ad01 on Jun 19, 2019
  16. PastaPastaPasta referenced this in commit 87e022842a on Jun 19, 2019
  17. PastaPastaPasta referenced this in commit 5f8dec42d0 on Jun 19, 2019
  18. PastaPastaPasta referenced this in commit 5b29dc6eeb on Jun 19, 2019
  19. PastaPastaPasta referenced this in commit e755b19a86 on Jun 19, 2019
  20. PastaPastaPasta referenced this in commit ffd6d8bf02 on Jun 20, 2019
  21. PastaPastaPasta referenced this in commit 4e3037285b on Jun 22, 2019
  22. PastaPastaPasta referenced this in commit d6e5c1b500 on Jun 22, 2019
  23. PastaPastaPasta referenced this in commit d4de8214ae on Jun 22, 2019
  24. PastaPastaPasta referenced this in commit aa4bba2a8e on Jun 22, 2019
  25. PastaPastaPasta referenced this in commit 7fdae3be98 on Jun 22, 2019
  26. PastaPastaPasta referenced this in commit ea3afb995f on Jun 24, 2019
  27. barrystyle referenced this in commit d42cf32b07 on Jan 22, 2020
  28. DrahtBot 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-04-30 12:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me