diff options
author | Rebecca Turner <rbt@sent.as> | 2024-08-26 09:28:14 -0700 |
---|---|---|
committer | Rebecca Turner <rbt@sent.as> | 2024-09-01 15:52:48 -0700 |
commit | 75c0de3e3cbd972328c7d0c6fdea79abbfa204df (patch) | |
tree | fd7217cf74435eb1d9d5abfcd75df33caa02fe50 /tests/unit/libutil-support | |
parent | 02eb07cfd539c34c080cb1baf042e5e780c1fcc2 (diff) |
Test including relative paths in configuration
Change-Id: If6c69a5e16d1ccd223fba392890f08f0032fb754
Diffstat (limited to 'tests/unit/libutil-support')
-rw-r--r-- | tests/unit/libutil-support/tests/characterization.hh | 9 | ||||
-rw-r--r-- | tests/unit/libutil-support/tests/test-data.cc | 16 | ||||
-rw-r--r-- | tests/unit/libutil-support/tests/test-data.hh | 20 |
3 files changed, 37 insertions, 8 deletions
diff --git a/tests/unit/libutil-support/tests/characterization.hh b/tests/unit/libutil-support/tests/characterization.hh index db82476da..2bf606bd8 100644 --- a/tests/unit/libutil-support/tests/characterization.hh +++ b/tests/unit/libutil-support/tests/characterization.hh @@ -9,18 +9,11 @@ #include <filesystem> #include "types.hh" +#include "test-data.hh" namespace nix { /** - * The path to the unit test data directory. See the contributing guide - * in the manual for further details. - */ -static Path getUnitTestData() { - return getEnv("_NIX_TEST_UNIT_DATA").value(); -} - -/** * Whether we should update "golden masters" instead of running tests * against them. See the contributing guide in the manual for further * details. diff --git a/tests/unit/libutil-support/tests/test-data.cc b/tests/unit/libutil-support/tests/test-data.cc new file mode 100644 index 000000000..016bd5e78 --- /dev/null +++ b/tests/unit/libutil-support/tests/test-data.cc @@ -0,0 +1,16 @@ +#include "test-data.hh" +#include "strings.hh" + +namespace nix { + +Path getUnitTestData() +{ + return getEnv("_NIX_TEST_UNIT_DATA").value(); +} + +Path getUnitTestDataPath(std::string_view path) +{ + return absPath(getUnitTestData() + "/" + path); +} + +} diff --git a/tests/unit/libutil-support/tests/test-data.hh b/tests/unit/libutil-support/tests/test-data.hh new file mode 100644 index 000000000..794ec6265 --- /dev/null +++ b/tests/unit/libutil-support/tests/test-data.hh @@ -0,0 +1,20 @@ +#pragma once + +#include "types.hh" +#include "environment-variables.hh" +#include "file-system.hh" + +namespace nix { + +/** + * The path to the unit test data directory. See the contributing guide + * in the manual for further details. + */ +Path getUnitTestData(); + +/** + * Resolve a path under the unit test data directory to an absolute path. + */ +Path getUnitTestDataPath(std::string_view path); + +} |