forked from lix-project/lix
Don't run libstore unit tests in project root
This keeps the libstore unit tests from writing
`libstore-unit-tests.xml` to the project root.
Change-Id: I0d9909aabf9f3574cc1e72a5ae81daefba9a394b
This commit is contained in:
parent
b323340538
commit
12f2565f91
25
tests/unit/libstore-support/tests/test-data.hh
Normal file
25
tests/unit/libstore-support/tests/test-data.hh
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "util.hh"
|
||||||
|
#include "types.hh"
|
||||||
|
|
||||||
|
namespace nix {
|
||||||
|
|
||||||
|
// TODO: These helpers should be available in all unit tests.
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resolve a path under the unit test data directory to an absolute path.
|
||||||
|
*/
|
||||||
|
static Path getUnitTestDataPath(std::string_view path) {
|
||||||
|
return absPath(getUnitTestData() + "/" + path);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
#include "machines.hh"
|
#include "machines.hh"
|
||||||
#include "globals.hh"
|
#include "globals.hh"
|
||||||
|
#include "tests/test-data.hh"
|
||||||
|
|
||||||
#include <gmock/gmock-matchers.h>
|
#include <gmock/gmock-matchers.h>
|
||||||
|
|
||||||
|
@ -17,7 +18,6 @@ using nix::getMachines;
|
||||||
using nix::Machine;
|
using nix::Machine;
|
||||||
using nix::Machines;
|
using nix::Machines;
|
||||||
using nix::pathExists;
|
using nix::pathExists;
|
||||||
using nix::Settings;
|
|
||||||
using nix::settings;
|
using nix::settings;
|
||||||
|
|
||||||
class Environment : public ::testing::Environment {
|
class Environment : public ::testing::Environment {
|
||||||
|
@ -138,7 +138,7 @@ TEST(machines, getMachinesWithIncorrectFormat) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(machines, getMachinesWithCorrectFileReference) {
|
TEST(machines, getMachinesWithCorrectFileReference) {
|
||||||
auto path = absPath("tests/unit/libstore/test-data/machines.valid");
|
auto path = nix::getUnitTestDataPath("machines.valid");
|
||||||
ASSERT_TRUE(pathExists(path));
|
ASSERT_TRUE(pathExists(path));
|
||||||
|
|
||||||
settings.builders = std::string("@") + path;
|
settings.builders = std::string("@") + path;
|
||||||
|
@ -165,6 +165,6 @@ TEST(machines, getMachinesWithIncorrectFileReference) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(machines, getMachinesWithCorrectFileReferenceToIncorrectFile) {
|
TEST(machines, getMachinesWithCorrectFileReferenceToIncorrectFile) {
|
||||||
settings.builders = std::string("@") + absPath("tests/unit/libstore/test-data/machines.bad_format");
|
settings.builders = std::string("@") + nix::getUnitTestDataPath("machines.bad_format");
|
||||||
EXPECT_THROW(getMachines(), FormatError);
|
EXPECT_THROW(getMachines(), FormatError);
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,6 +85,7 @@ libstore_test_support_sources = files(
|
||||||
'libstore-support/tests/derived-path.cc',
|
'libstore-support/tests/derived-path.cc',
|
||||||
'libstore-support/tests/outputs-spec.cc',
|
'libstore-support/tests/outputs-spec.cc',
|
||||||
'libstore-support/tests/path.cc',
|
'libstore-support/tests/path.cc',
|
||||||
|
'libstore-support/tests/test-data.hh',
|
||||||
)
|
)
|
||||||
|
|
||||||
libstore_test_support = library(
|
libstore_test_support = library(
|
||||||
|
@ -142,7 +143,6 @@ test(
|
||||||
'_NIX_TEST_UNIT_DATA': meson.project_source_root() / 'tests/unit/libstore/data',
|
'_NIX_TEST_UNIT_DATA': meson.project_source_root() / 'tests/unit/libstore/data',
|
||||||
},
|
},
|
||||||
suite : 'check',
|
suite : 'check',
|
||||||
workdir : meson.project_source_root(),
|
|
||||||
protocol : 'gtest',
|
protocol : 'gtest',
|
||||||
verbose : true,
|
verbose : true,
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue