From 8d554a9fb5677b076223dde8587ab63330880418 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Fri, 25 Aug 2023 10:20:28 -0400 Subject: [PATCH] Move tests to separate directories, and document Today, with the tests inside a `tests` intermingled with the corresponding library's source code, we have a few problems: - We have to be careful that wildcards don't end up with tests being built as part of Nix proper, or test headers being installed as part of Nix proper. - Understanding `#include` resolution is very hard, because files instead `tests` directories can shadow those outside by mistake. This solves the first problem and partially solves the second problem --- test headers still need to live inside a `tests` directory, but at least regular `*.cc` files for tests do not. Co-authored-by: Valentin Gagarin --- .gitignore | 6 +-- Makefile | 6 +-- doc/internal-api/doxygen.cfg.in | 12 ++++-- doc/manual/src/contributing/testing.md | 42 ++++++++++++++++--- .../tests => libexpr-tests}/derived-path.cc | 4 +- .../tests => libexpr-tests}/error_traces.cc | 2 +- .../tests => libexpr-tests}/flakeref.cc | 0 src/{libexpr/tests => libexpr-tests}/json.cc | 2 +- src/libexpr-tests/local.mk | 28 +++++++++++++ .../tests => libexpr-tests}/primops.cc | 2 +- .../tests => libexpr-tests}/search-path.cc | 0 .../tests => libexpr-tests/test}/libexpr.hh | 2 +- .../test}/value/context.hh | 2 +- .../test}/value/print.cc | 2 +- .../tests => libexpr-tests}/trivial.cc | 2 +- .../tests => libexpr-tests}/value/context.cc | 6 +-- src/libexpr/tests/local.mk | 19 --------- .../common-protocol.cc | 4 +- .../tests => libstore-tests}/derivation.cc | 2 +- .../tests => libstore-tests}/derived-path.cc | 4 +- .../downstream-placeholder.cc | 0 .../tests => libstore-tests}/local.mk | 12 ++++-- .../tests => libstore-tests}/machines.cc | 4 +- .../nar-info-disk-cache.cc | 0 .../tests => libstore-tests}/outputs-spec.cc | 2 +- .../tests => libstore-tests}/path.cc | 6 +-- .../tests => libstore-tests}/references.cc | 0 .../serve-protocol.cc | 4 +- .../test-data/machines.bad_format | 0 .../test-data/machines.valid | 0 .../test}/characterization.hh | 0 .../test}/derived-path.hh | 4 +- .../tests => libstore-tests/test}/libstore.hh | 0 .../test}/outputs-spec.hh | 2 +- .../tests => libstore-tests/test}/path.hh | 0 .../tests => libstore-tests/test}/protocol.hh | 4 +- .../worker-protocol.cc | 4 +- .../tests => libutil-tests}/canon-path.cc | 0 .../tests => libutil-tests}/chunked-vector.cc | 0 .../tests => libutil-tests}/closure.cc | 0 .../tests => libutil-tests}/compression.cc | 0 .../tests => libutil-tests}/config.cc | 0 src/{libutil/tests => libutil-tests}/git.cc | 0 src/{libutil/tests => libutil-tests}/hash.cc | 4 +- .../tests => libutil-tests}/hilite.cc | 0 src/{libutil/tests => libutil-tests}/local.mk | 4 +- .../tests => libutil-tests}/logging.cc | 0 .../tests => libutil-tests}/lru-cache.cc | 0 src/{libutil/tests => libutil-tests}/pool.cc | 0 .../tests => libutil-tests}/references.cc | 0 .../tests => libutil-tests}/suggestions.cc | 0 .../tests => libutil-tests/test}/hash.hh | 0 src/{libutil/tests => libutil-tests}/tests.cc | 0 src/{libutil/tests => libutil-tests}/url.cc | 0 .../tests => libutil-tests}/xml-writer.cc | 0 55 files changed, 124 insertions(+), 73 deletions(-) rename src/{libexpr/tests => libexpr-tests}/derived-path.cc (96%) rename src/{libexpr/tests => libexpr-tests}/error_traces.cc (99%) rename src/{libexpr/tests => libexpr-tests}/flakeref.cc (100%) rename src/{libexpr/tests => libexpr-tests}/json.cc (98%) create mode 100644 src/libexpr-tests/local.mk rename src/{libexpr/tests => libexpr-tests}/primops.cc (99%) rename src/{libexpr/tests => libexpr-tests}/search-path.cc (100%) rename src/{libexpr/tests => libexpr-tests/test}/libexpr.hh (99%) rename src/{libexpr/tests => libexpr-tests/test}/value/context.hh (95%) rename src/{libexpr/tests => libexpr-tests/test}/value/print.cc (99%) rename src/{libexpr/tests => libexpr-tests}/trivial.cc (99%) rename src/{libexpr/tests => libexpr-tests}/value/context.cc (98%) delete mode 100644 src/libexpr/tests/local.mk rename src/{libstore/tests => libstore-tests}/common-protocol.cc (98%) rename src/{libstore/tests => libstore-tests}/derivation.cc (99%) rename src/{libstore/tests => libstore-tests}/derived-path.cc (98%) rename src/{libstore/tests => libstore-tests}/downstream-placeholder.cc (100%) rename src/{libstore/tests => libstore-tests}/local.mk (72%) rename src/{libstore/tests => libstore-tests}/machines.cc (98%) rename src/{libstore/tests => libstore-tests}/nar-info-disk-cache.cc (100%) rename src/{libstore/tests => libstore-tests}/outputs-spec.cc (99%) rename src/{libstore/tests => libstore-tests}/path.cc (98%) rename src/{libstore/tests => libstore-tests}/references.cc (100%) rename src/{libstore/tests => libstore-tests}/serve-protocol.cc (99%) rename src/{libstore/tests => libstore-tests}/test-data/machines.bad_format (100%) rename src/{libstore/tests => libstore-tests}/test-data/machines.valid (100%) rename src/{libstore/tests => libstore-tests/test}/characterization.hh (100%) rename src/{libstore/tests => libstore-tests/test}/derived-path.hh (91%) rename src/{libstore/tests => libstore-tests/test}/libstore.hh (100%) rename src/{libstore/tests => libstore-tests/test}/outputs-spec.hh (89%) rename src/{libstore/tests => libstore-tests/test}/path.hh (100%) rename src/{libstore/tests => libstore-tests/test}/protocol.hh (97%) rename src/{libstore/tests => libstore-tests}/worker-protocol.cc (99%) rename src/{libutil/tests => libutil-tests}/canon-path.cc (100%) rename src/{libutil/tests => libutil-tests}/chunked-vector.cc (100%) rename src/{libutil/tests => libutil-tests}/closure.cc (100%) rename src/{libutil/tests => libutil-tests}/compression.cc (100%) rename src/{libutil/tests => libutil-tests}/config.cc (100%) rename src/{libutil/tests => libutil-tests}/git.cc (100%) rename src/{libutil/tests => libutil-tests}/hash.cc (98%) rename src/{libutil/tests => libutil-tests}/hilite.cc (100%) rename src/{libutil/tests => libutil-tests}/local.mk (87%) rename src/{libutil/tests => libutil-tests}/logging.cc (100%) rename src/{libutil/tests => libutil-tests}/lru-cache.cc (100%) rename src/{libutil/tests => libutil-tests}/pool.cc (100%) rename src/{libutil/tests => libutil-tests}/references.cc (100%) rename src/{libutil/tests => libutil-tests}/suggestions.cc (100%) rename src/{libutil/tests => libutil-tests/test}/hash.hh (100%) rename src/{libutil/tests => libutil-tests}/tests.cc (100%) rename src/{libutil/tests => libutil-tests}/url.cc (100%) rename src/{libutil/tests => libutil-tests}/xml-writer.cc (100%) diff --git a/.gitignore b/.gitignore index 04d96ca2c091..77e8f5111bdc 100644 --- a/.gitignore +++ b/.gitignore @@ -41,14 +41,14 @@ perl/Makefile.config /src/libexpr/parser-tab.hh /src/libexpr/parser-tab.output /src/libexpr/nix.tbl -/src/libexpr/tests/libnixexpr-tests +/src/libexpr-tests/libnixexpr-tests # /src/libstore/ *.gen.* -/src/libstore/tests/libnixstore-tests +/src/libstore-tests/libnixstore-tests # /src/libutil/ -/src/libutil/tests/libnixutil-tests +/src/libutil-tests/libnixutil-tests /src/nix/nix diff --git a/Makefile b/Makefile index 4f4ac0c6e295..9002264e4ae8 100644 --- a/Makefile +++ b/Makefile @@ -27,9 +27,9 @@ endif ifeq ($(ENABLE_BUILD)_$(ENABLE_TESTS), yes_yes) UNIT_TEST_ENV = _NIX_TEST_UNIT_DATA=unit-test-data makefiles += \ - src/libutil/tests/local.mk \ - src/libstore/tests/local.mk \ - src/libexpr/tests/local.mk + src/libutil-tests/local.mk \ + src/libstore-tests/local.mk \ + src/libexpr-tests/local.mk endif ifeq ($(ENABLE_TESTS), yes) diff --git a/doc/internal-api/doxygen.cfg.in b/doc/internal-api/doxygen.cfg.in index 599be2470b8f..b3082c708e5d 100644 --- a/doc/internal-api/doxygen.cfg.in +++ b/doc/internal-api/doxygen.cfg.in @@ -39,17 +39,21 @@ INPUT = \ src/libcmd \ src/libexpr \ src/libexpr/flake \ - src/libexpr/tests \ - src/libexpr/tests/value \ + src/libexpr-tests \ + src/libexpr-tests/value \ + src/libexpr-tests/test \ + src/libexpr-tests/test/value \ src/libexpr/value \ src/libfetchers \ src/libmain \ src/libstore \ src/libstore/build \ src/libstore/builtins \ - src/libstore/tests \ + src/libstore-tests \ + src/libstore-tests/test \ src/libutil \ - src/libutil/tests \ + src/libutil-tests \ + src/libutil-tests/test \ src/nix \ src/nix-env \ src/nix-store diff --git a/doc/manual/src/contributing/testing.md b/doc/manual/src/contributing/testing.md index 3d75ebe7b560..8131d313522e 100644 --- a/doc/manual/src/contributing/testing.md +++ b/doc/manual/src/contributing/testing.md @@ -32,11 +32,15 @@ The unit tests are defined using the [googletest] and [rapidcheck] frameworks. > │ ├── value/context.cc > │ │ > │ … -> └── tests -> │ ├── value/context.hh -> │ ├── value/context.cc -> │ │ -> │ … +> │ +> ├── libexpr-tests +> │ ├── test/ +> │ │ ├── value/context.hh +> │ │ │ +> │ │ … +> │ ├── value/context.cc +> │ │ +> │ … > │ > ├── unit-test-data > │ ├── libstore @@ -46,7 +50,12 @@ The unit tests are defined using the [googletest] and [rapidcheck] frameworks. > … > ``` -The unit tests for each Nix library (`libnixexpr`, `libnixstore`, etc..) live inside a directory `src/${library_shortname}/tests` within the directory for the library (`src/${library_shortname}`). +The tests for each Nix library (`libnixexpr`, `libnixstore`, etc..) live inside a directory `src/${library_name_without-nix}-tests` next to the directory for the library (`src/${library_name_without-nix}`). +Given a interface (header) and implementation pair in the original library, say, `libexpr/value/context.{hh,cc}`, we write tests for it in `libexpr-tests/value/context.cc`, and (possibly) declare additional interfaces for testing purposes in `libexpr-tests/test/value/context.hh`. + +> **Note** +> +> Only the extra header is nested inside the `test` directory. This is explained further below. The data is in `unit-test-data`, with one subdir per library, with the same name as where the code goes. For example, `libnixstore` code is in `src/libstore`, and its test data is in `unit-test-data/libstore`. @@ -57,6 +66,27 @@ The path to the `unit-test-data` directory is passed to the unit test executable > Therefore it is important that the same value for `_NIX_TEST_UNIT_DATA` be used with the tests for each library. > That is why we have the test data nested within a single `unit-test-data` directory. +### Rationale + +The use of a separate directory for the unit tests might seem inconvenient, as the tests are not "right next to" the part of the code they are testing. +But organizing the tests this way has one big benefit: +there is no risk of any build-system wildcards for the library accidentally picking up test code that shoud not built and installed as part of the library. + +Likewise, the use of the `test/` subdir might seem superfluous: +Isn't the point of the `*-test` subdir to indicate that these files are tests? +Why do we need another `test` subdirectory? +The answer is that we need to be able to tell apart the two headers, and make sure we include the right one. +For `.cc` files, this is matter of doing `#include "foo.hh"` vs `#include "test/foo.hh` +For `.hh` files, this is a bit more subtle, because a `#include "foo.hh` instead `test/foo.hh` will end up including itself because `#include "..."` +[always prioritizes files in the same directory](https://pubs.opengroup.org/onlinepubs/9699919799/utilities/c99.html#tag_20_11_04), rather than the original header from the library. +Instead, use `#include ` to get the original library header, and `#include "test/foo.hh"` to get the test header. + +Why do we have test headers at all? +These are usually for [rapidcheck]'s `Arbitrary` machinery, which is used to describe how to generate values of a given type for the sake of running property tests. +Because types contain other types, `Arbitrary` "instances" for some type are not just useful for testing that type, but also any other type that contains it. +Indeed, if we don't reuse the upstream type's `Arbitrary` instance, the downstream type's `Arbitrary` instance would become much more complex and hard to understand. +In order to reuse these instances, we therefore declare them in these testing headers. + ### Running tests You can run the whole testsuite with `make check`, or the tests for a specific component with `make libfoo-tests_RUN`. diff --git a/src/libexpr/tests/derived-path.cc b/src/libexpr-tests/derived-path.cc similarity index 96% rename from src/libexpr/tests/derived-path.cc rename to src/libexpr-tests/derived-path.cc index d5fc6f201557..e6bf1f69b259 100644 --- a/src/libexpr/tests/derived-path.cc +++ b/src/libexpr-tests/derived-path.cc @@ -2,8 +2,8 @@ #include #include -#include "tests/derived-path.hh" -#include "tests/libexpr.hh" +#include "test/derived-path.hh" +#include "test/libexpr.hh" namespace nix { diff --git a/src/libexpr/tests/error_traces.cc b/src/libexpr-tests/error_traces.cc similarity index 99% rename from src/libexpr/tests/error_traces.cc rename to src/libexpr-tests/error_traces.cc index 139366bcd161..7e8837d682aa 100644 --- a/src/libexpr/tests/error_traces.cc +++ b/src/libexpr-tests/error_traces.cc @@ -1,7 +1,7 @@ #include #include -#include "tests/libexpr.hh" +#include "test/libexpr.hh" namespace nix { diff --git a/src/libexpr/tests/flakeref.cc b/src/libexpr-tests/flakeref.cc similarity index 100% rename from src/libexpr/tests/flakeref.cc rename to src/libexpr-tests/flakeref.cc diff --git a/src/libexpr/tests/json.cc b/src/libexpr-tests/json.cc similarity index 98% rename from src/libexpr/tests/json.cc rename to src/libexpr-tests/json.cc index f4cc118d6645..5195d80c224a 100644 --- a/src/libexpr/tests/json.cc +++ b/src/libexpr-tests/json.cc @@ -1,4 +1,4 @@ -#include "tests/libexpr.hh" +#include "test/libexpr.hh" #include "value-to-json.hh" namespace nix { diff --git a/src/libexpr-tests/local.mk b/src/libexpr-tests/local.mk new file mode 100644 index 000000000000..38ee6f9f986f --- /dev/null +++ b/src/libexpr-tests/local.mk @@ -0,0 +1,28 @@ +check: libexpr-tests_RUN + +programs += libexpr-tests + +libexpr-tests_NAME := libnixexpr-tests + +libexpr-tests_DIR := $(d) + +libexpr-tests_INSTALL_DIR := + +libexpr-tests_SOURCES := \ + $(wildcard $(d)/*.cc) \ + $(wildcard $(d)/value/*.cc) + +libexpr-tests_CXXFLAGS += \ + -I src/libexpr-tests \ + -I src/libstore-tests \ + -I src/libutil-tests \ + -I src/libexpr \ + -I src/libfetchers \ + -I src/libstore \ + -I src/libutil + +libexpr-tests_LIBS = \ + libstore-tests libutils-tests \ + libexpr libfetchers libstore libutil + +libexpr-tests_LDFLAGS := $(GTEST_LIBS) -lgmock diff --git a/src/libexpr/tests/primops.cc b/src/libexpr-tests/primops.cc similarity index 99% rename from src/libexpr/tests/primops.cc rename to src/libexpr-tests/primops.cc index d820b860e7cf..934043e03498 100644 --- a/src/libexpr/tests/primops.cc +++ b/src/libexpr-tests/primops.cc @@ -1,7 +1,7 @@ #include #include -#include "tests/libexpr.hh" +#include "test/libexpr.hh" namespace nix { class CaptureLogger : public Logger diff --git a/src/libexpr/tests/search-path.cc b/src/libexpr-tests/search-path.cc similarity index 100% rename from src/libexpr/tests/search-path.cc rename to src/libexpr-tests/search-path.cc diff --git a/src/libexpr/tests/libexpr.hh b/src/libexpr-tests/test/libexpr.hh similarity index 99% rename from src/libexpr/tests/libexpr.hh rename to src/libexpr-tests/test/libexpr.hh index 9684314469e8..7e095e5dd0c8 100644 --- a/src/libexpr/tests/libexpr.hh +++ b/src/libexpr-tests/test/libexpr.hh @@ -10,7 +10,7 @@ #include "eval-inline.hh" #include "store-api.hh" -#include "tests/libstore.hh" +#include "test/libstore.hh" namespace nix { class LibExprTest : public LibStoreTest { diff --git a/src/libexpr/tests/value/context.hh b/src/libexpr-tests/test/value/context.hh similarity index 95% rename from src/libexpr/tests/value/context.hh rename to src/libexpr-tests/test/value/context.hh index c0bc97ba3c46..8c68c78bbd1c 100644 --- a/src/libexpr/tests/value/context.hh +++ b/src/libexpr-tests/test/value/context.hh @@ -3,7 +3,7 @@ #include -#include +#include "value/context.hh" namespace rc { using namespace nix; diff --git a/src/libexpr/tests/value/print.cc b/src/libexpr-tests/test/value/print.cc similarity index 99% rename from src/libexpr/tests/value/print.cc rename to src/libexpr-tests/test/value/print.cc index 5e96e12ec7d3..b95c41836d41 100644 --- a/src/libexpr/tests/value/print.cc +++ b/src/libexpr-tests/test/value/print.cc @@ -1,4 +1,4 @@ -#include "tests/libexpr.hh" +#include "test/libexpr.hh" #include "value.hh" diff --git a/src/libexpr/tests/trivial.cc b/src/libexpr-tests/trivial.cc similarity index 99% rename from src/libexpr/tests/trivial.cc rename to src/libexpr-tests/trivial.cc index 171727ac71bd..8dacf9f7c77f 100644 --- a/src/libexpr/tests/trivial.cc +++ b/src/libexpr-tests/trivial.cc @@ -1,4 +1,4 @@ -#include "tests/libexpr.hh" +#include "test/libexpr.hh" namespace nix { // Testing of trivial expressions diff --git a/src/libexpr/tests/value/context.cc b/src/libexpr-tests/value/context.cc similarity index 98% rename from src/libexpr/tests/value/context.cc rename to src/libexpr-tests/value/context.cc index 92d4889abde6..099e185e8903 100644 --- a/src/libexpr/tests/value/context.cc +++ b/src/libexpr-tests/value/context.cc @@ -2,9 +2,9 @@ #include #include -#include "tests/path.hh" -#include "tests/libexpr.hh" -#include "tests/value/context.hh" +#include "test/path.hh" +#include "test/libexpr.hh" +#include "test/value/context.hh" namespace nix { diff --git a/src/libexpr/tests/local.mk b/src/libexpr/tests/local.mk deleted file mode 100644 index 331a5ead60e4..000000000000 --- a/src/libexpr/tests/local.mk +++ /dev/null @@ -1,19 +0,0 @@ -check: libexpr-tests_RUN - -programs += libexpr-tests - -libexpr-tests_NAME := libnixexpr-tests - -libexpr-tests_DIR := $(d) - -libexpr-tests_INSTALL_DIR := - -libexpr-tests_SOURCES := \ - $(wildcard $(d)/*.cc) \ - $(wildcard $(d)/value/*.cc) - -libexpr-tests_CXXFLAGS += -I src/libexpr -I src/libutil -I src/libstore -I src/libexpr/tests -I src/libfetchers - -libexpr-tests_LIBS = libstore-tests libutils-tests libexpr libutil libstore libfetchers - -libexpr-tests_LDFLAGS := $(GTEST_LIBS) -lgmock diff --git a/src/libstore/tests/common-protocol.cc b/src/libstore-tests/common-protocol.cc similarity index 98% rename from src/libstore/tests/common-protocol.cc rename to src/libstore-tests/common-protocol.cc index 61c2cb70cb19..876b032f6cf6 100644 --- a/src/libstore/tests/common-protocol.cc +++ b/src/libstore-tests/common-protocol.cc @@ -6,8 +6,8 @@ #include "common-protocol.hh" #include "common-protocol-impl.hh" #include "build-result.hh" -#include "tests/protocol.hh" -#include "tests/characterization.hh" +#include "test/protocol.hh" +#include "test/characterization.hh" namespace nix { diff --git a/src/libstore/tests/derivation.cc b/src/libstore-tests/derivation.cc similarity index 99% rename from src/libstore/tests/derivation.cc rename to src/libstore-tests/derivation.cc index c360c9707f4e..3f3d06412880 100644 --- a/src/libstore/tests/derivation.cc +++ b/src/libstore-tests/derivation.cc @@ -4,7 +4,7 @@ #include "experimental-features.hh" #include "derivations.hh" -#include "tests/libstore.hh" +#include "test/libstore.hh" namespace nix { diff --git a/src/libstore/tests/derived-path.cc b/src/libstore-tests/derived-path.cc similarity index 98% rename from src/libstore/tests/derived-path.cc rename to src/libstore-tests/derived-path.cc index 3fa3c080181d..0f8f32d1a3b3 100644 --- a/src/libstore/tests/derived-path.cc +++ b/src/libstore-tests/derived-path.cc @@ -4,8 +4,8 @@ #include #include -#include "tests/derived-path.hh" -#include "tests/libstore.hh" +#include "test/derived-path.hh" +#include "test/libstore.hh" namespace rc { using namespace nix; diff --git a/src/libstore/tests/downstream-placeholder.cc b/src/libstore-tests/downstream-placeholder.cc similarity index 100% rename from src/libstore/tests/downstream-placeholder.cc rename to src/libstore-tests/downstream-placeholder.cc diff --git a/src/libstore/tests/local.mk b/src/libstore-tests/local.mk similarity index 72% rename from src/libstore/tests/local.mk rename to src/libstore-tests/local.mk index 03becc7d11b6..59b995a1a02b 100644 --- a/src/libstore/tests/local.mk +++ b/src/libstore-tests/local.mk @@ -22,8 +22,14 @@ libstore-tests_INSTALL_DIR := libstore-tests_SOURCES := $(wildcard $(d)/*.cc) -libstore-tests_CXXFLAGS += -I src/libstore -I src/libutil - -libstore-tests_LIBS = libutil-tests libstore libutil +libstore-tests_CXXFLAGS += \ + -I src/libstore-tests \ + -I src/libutil-tests \ + -I src/libstore \ + -I src/libutil + +libstore-tests_LIBS = \ + libutil-tests \ + libstore libutil libstore-tests_LDFLAGS := -lrapidcheck $(GTEST_LIBS) diff --git a/src/libstore/tests/machines.cc b/src/libstore-tests/machines.cc similarity index 98% rename from src/libstore/tests/machines.cc rename to src/libstore-tests/machines.cc index f51052b14626..e0a66837cb71 100644 --- a/src/libstore/tests/machines.cc +++ b/src/libstore-tests/machines.cc @@ -137,7 +137,7 @@ TEST(machines, getMachinesWithIncorrectFormat) { } TEST(machines, getMachinesWithCorrectFileReference) { - auto path = absPath("src/libstore/tests/test-data/machines.valid"); + auto path = absPath("src/libstore-tests/test-data/machines.valid"); ASSERT_TRUE(pathExists(path)); settings.builders = std::string("@") + path; @@ -164,6 +164,6 @@ TEST(machines, getMachinesWithIncorrectFileReference) { } TEST(machines, getMachinesWithCorrectFileReferenceToIncorrectFile) { - settings.builders = std::string("@") + absPath("src/libstore/tests/test-data/machines.bad_format"); + settings.builders = std::string("@") + absPath("src/libstore-tests/test-data/machines.bad_format"); EXPECT_THROW(getMachines(), FormatError); } diff --git a/src/libstore/tests/nar-info-disk-cache.cc b/src/libstore-tests/nar-info-disk-cache.cc similarity index 100% rename from src/libstore/tests/nar-info-disk-cache.cc rename to src/libstore-tests/nar-info-disk-cache.cc diff --git a/src/libstore/tests/outputs-spec.cc b/src/libstore-tests/outputs-spec.cc similarity index 99% rename from src/libstore/tests/outputs-spec.cc rename to src/libstore-tests/outputs-spec.cc index 95294518544b..5ad07327cfce 100644 --- a/src/libstore/tests/outputs-spec.cc +++ b/src/libstore-tests/outputs-spec.cc @@ -1,4 +1,4 @@ -#include "outputs-spec.hh" +#include "test/outputs-spec.hh" #include #include diff --git a/src/libstore/tests/path.cc b/src/libstore-tests/path.cc similarity index 98% rename from src/libstore/tests/path.cc rename to src/libstore-tests/path.cc index 5a84d646c25b..869ec7d7e605 100644 --- a/src/libstore/tests/path.cc +++ b/src/libstore-tests/path.cc @@ -7,9 +7,9 @@ #include "path-regex.hh" #include "store-api.hh" -#include "tests/hash.hh" -#include "tests/libstore.hh" -#include "tests/path.hh" +#include "test/hash.hh" +#include "test/libstore.hh" +#include "test/path.hh" namespace nix { diff --git a/src/libstore/tests/references.cc b/src/libstore-tests/references.cc similarity index 100% rename from src/libstore/tests/references.cc rename to src/libstore-tests/references.cc diff --git a/src/libstore/tests/serve-protocol.cc b/src/libstore-tests/serve-protocol.cc similarity index 99% rename from src/libstore/tests/serve-protocol.cc rename to src/libstore-tests/serve-protocol.cc index c8ac87a04ced..3b516e35462b 100644 --- a/src/libstore/tests/serve-protocol.cc +++ b/src/libstore-tests/serve-protocol.cc @@ -6,8 +6,8 @@ #include "serve-protocol.hh" #include "serve-protocol-impl.hh" #include "build-result.hh" -#include "tests/protocol.hh" -#include "tests/characterization.hh" +#include "test/protocol.hh" +#include "test/characterization.hh" namespace nix { diff --git a/src/libstore/tests/test-data/machines.bad_format b/src/libstore-tests/test-data/machines.bad_format similarity index 100% rename from src/libstore/tests/test-data/machines.bad_format rename to src/libstore-tests/test-data/machines.bad_format diff --git a/src/libstore/tests/test-data/machines.valid b/src/libstore-tests/test-data/machines.valid similarity index 100% rename from src/libstore/tests/test-data/machines.valid rename to src/libstore-tests/test-data/machines.valid diff --git a/src/libstore/tests/characterization.hh b/src/libstore-tests/test/characterization.hh similarity index 100% rename from src/libstore/tests/characterization.hh rename to src/libstore-tests/test/characterization.hh diff --git a/src/libstore/tests/derived-path.hh b/src/libstore-tests/test/derived-path.hh similarity index 91% rename from src/libstore/tests/derived-path.hh rename to src/libstore-tests/test/derived-path.hh index 98d61f2283d2..4edbfa6e07fd 100644 --- a/src/libstore/tests/derived-path.hh +++ b/src/libstore-tests/test/derived-path.hh @@ -5,8 +5,8 @@ #include -#include "tests/path.hh" -#include "tests/outputs-spec.hh" +#include "test/path.hh" +#include "test/outputs-spec.hh" namespace rc { using namespace nix; diff --git a/src/libstore/tests/libstore.hh b/src/libstore-tests/test/libstore.hh similarity index 100% rename from src/libstore/tests/libstore.hh rename to src/libstore-tests/test/libstore.hh diff --git a/src/libstore/tests/outputs-spec.hh b/src/libstore-tests/test/outputs-spec.hh similarity index 89% rename from src/libstore/tests/outputs-spec.hh rename to src/libstore-tests/test/outputs-spec.hh index ded331b333e3..b60cbaba15c1 100644 --- a/src/libstore/tests/outputs-spec.hh +++ b/src/libstore-tests/test/outputs-spec.hh @@ -5,7 +5,7 @@ #include -#include +#include "test/path.hh" namespace rc { using namespace nix; diff --git a/src/libstore/tests/path.hh b/src/libstore-tests/test/path.hh similarity index 100% rename from src/libstore/tests/path.hh rename to src/libstore-tests/test/path.hh diff --git a/src/libstore/tests/protocol.hh b/src/libstore-tests/test/protocol.hh similarity index 97% rename from src/libstore/tests/protocol.hh rename to src/libstore-tests/test/protocol.hh index 496915745274..3d215889e15f 100644 --- a/src/libstore/tests/protocol.hh +++ b/src/libstore-tests/test/protocol.hh @@ -1,8 +1,8 @@ #include #include -#include "tests/libstore.hh" -#include "tests/characterization.hh" +#include "test/libstore.hh" +#include "test/characterization.hh" namespace nix { diff --git a/src/libstore/tests/worker-protocol.cc b/src/libstore-tests/worker-protocol.cc similarity index 99% rename from src/libstore/tests/worker-protocol.cc rename to src/libstore-tests/worker-protocol.cc index ad5943c69bc4..b4d31208d589 100644 --- a/src/libstore/tests/worker-protocol.cc +++ b/src/libstore-tests/worker-protocol.cc @@ -7,8 +7,8 @@ #include "worker-protocol-impl.hh" #include "derived-path.hh" #include "build-result.hh" -#include "tests/protocol.hh" -#include "tests/characterization.hh" +#include "test/protocol.hh" +#include "test/characterization.hh" namespace nix { diff --git a/src/libutil/tests/canon-path.cc b/src/libutil-tests/canon-path.cc similarity index 100% rename from src/libutil/tests/canon-path.cc rename to src/libutil-tests/canon-path.cc diff --git a/src/libutil/tests/chunked-vector.cc b/src/libutil-tests/chunked-vector.cc similarity index 100% rename from src/libutil/tests/chunked-vector.cc rename to src/libutil-tests/chunked-vector.cc diff --git a/src/libutil/tests/closure.cc b/src/libutil-tests/closure.cc similarity index 100% rename from src/libutil/tests/closure.cc rename to src/libutil-tests/closure.cc diff --git a/src/libutil/tests/compression.cc b/src/libutil-tests/compression.cc similarity index 100% rename from src/libutil/tests/compression.cc rename to src/libutil-tests/compression.cc diff --git a/src/libutil/tests/config.cc b/src/libutil-tests/config.cc similarity index 100% rename from src/libutil/tests/config.cc rename to src/libutil-tests/config.cc diff --git a/src/libutil/tests/git.cc b/src/libutil-tests/git.cc similarity index 100% rename from src/libutil/tests/git.cc rename to src/libutil-tests/git.cc diff --git a/src/libutil/tests/hash.cc b/src/libutil-tests/hash.cc similarity index 98% rename from src/libutil/tests/hash.cc rename to src/libutil-tests/hash.cc index 9a5ebbb30fdc..bb9b300b7c18 100644 --- a/src/libutil/tests/hash.cc +++ b/src/libutil-tests/hash.cc @@ -4,9 +4,9 @@ #include #include -#include +#include "hash.hh" -#include "tests/hash.hh" +#include "test/hash.hh" namespace nix { diff --git a/src/libutil/tests/hilite.cc b/src/libutil-tests/hilite.cc similarity index 100% rename from src/libutil/tests/hilite.cc rename to src/libutil-tests/hilite.cc diff --git a/src/libutil/tests/local.mk b/src/libutil-tests/local.mk similarity index 87% rename from src/libutil/tests/local.mk rename to src/libutil-tests/local.mk index 167915439fd0..3b0382eec533 100644 --- a/src/libutil/tests/local.mk +++ b/src/libutil-tests/local.mk @@ -22,7 +22,9 @@ libutil-tests_INSTALL_DIR := libutil-tests_SOURCES := $(wildcard $(d)/*.cc) -libutil-tests_CXXFLAGS += -I src/libutil +libutil-tests_CXXFLAGS += \ + -I src/libutil-tests \ + -I src/libutil libutil-tests_LIBS = libutil diff --git a/src/libutil/tests/logging.cc b/src/libutil-tests/logging.cc similarity index 100% rename from src/libutil/tests/logging.cc rename to src/libutil-tests/logging.cc diff --git a/src/libutil/tests/lru-cache.cc b/src/libutil-tests/lru-cache.cc similarity index 100% rename from src/libutil/tests/lru-cache.cc rename to src/libutil-tests/lru-cache.cc diff --git a/src/libutil/tests/pool.cc b/src/libutil-tests/pool.cc similarity index 100% rename from src/libutil/tests/pool.cc rename to src/libutil-tests/pool.cc diff --git a/src/libutil/tests/references.cc b/src/libutil-tests/references.cc similarity index 100% rename from src/libutil/tests/references.cc rename to src/libutil-tests/references.cc diff --git a/src/libutil/tests/suggestions.cc b/src/libutil-tests/suggestions.cc similarity index 100% rename from src/libutil/tests/suggestions.cc rename to src/libutil-tests/suggestions.cc diff --git a/src/libutil/tests/hash.hh b/src/libutil-tests/test/hash.hh similarity index 100% rename from src/libutil/tests/hash.hh rename to src/libutil-tests/test/hash.hh diff --git a/src/libutil/tests/tests.cc b/src/libutil-tests/tests.cc similarity index 100% rename from src/libutil/tests/tests.cc rename to src/libutil-tests/tests.cc diff --git a/src/libutil/tests/url.cc b/src/libutil-tests/url.cc similarity index 100% rename from src/libutil/tests/url.cc rename to src/libutil-tests/url.cc diff --git a/src/libutil/tests/xml-writer.cc b/src/libutil-tests/xml-writer.cc similarity index 100% rename from src/libutil/tests/xml-writer.cc rename to src/libutil-tests/xml-writer.cc