From cb96be9a6e6154775d102f8ea0c501f29e70f84b Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Fri, 6 Sep 2019 13:30:45 +0200 Subject: [PATCH] pytest: Allow running tests in a shared memory directory It seems we spend a lot of time waiting for `bitcoind` and `lightningd` to talk to disks. This adds the `TEST_DIR` environment variable, allowing for example to use `/dev/shm`, or a faster disk than the disk `/tmp` is on, as the root directory for all test-related files. Testing this on one of our builder machines cut the time to run the entire suite under valgrind roughly in half (180-200 seconds vs 440-490 seconds). --- tests/fixtures.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/fixtures.py b/tests/fixtures.py index 193c17b25..a8288bf91 100644 --- a/tests/fixtures.py +++ b/tests/fixtures.py @@ -29,7 +29,9 @@ __attempts = {} @pytest.fixture(scope="session") def test_base_dir(): - directory = tempfile.mkdtemp(prefix='ltests-') + d = os.getenv("TEST_DIR", "/tmp") + + directory = tempfile.mkdtemp(prefix='ltests-', dir=d) print("Running tests in {}".format(directory)) yield directory