feat(tvix): Re-enable language tests that needed a store
Now that we have access to a store in tests, we can enable the tests that needed a store. Additionally, move the expected output files for disabled tests into the disabled folder. Change-Id: I2492d49d43b93c7c9b0463e4d3d2855a5a51365d Reviewed-on: https://cl.tvl.fyi/c/depot/+/1758 Tested-by: BuildkiteCI Reviewed-by: glittershark <grfn@gws.fyi>
This commit is contained in:
parent
fea4df560b
commit
b76cd7253a
14 changed files with 59 additions and 9 deletions
52
third_party/nix/src/tests/language-tests.cc
vendored
52
third_party/nix/src/tests/language-tests.cc
vendored
|
|
@ -46,6 +46,7 @@
|
|||
#include "libexpr/nixexpr.hh"
|
||||
#include "nix_config.h"
|
||||
#include "tests/dummy-store.hh"
|
||||
#include "tests/store-util.hh"
|
||||
|
||||
namespace nix::tests {
|
||||
namespace {
|
||||
|
|
@ -208,7 +209,7 @@ INSTANTIATE_TEST_SUITE_P(Eval, EvalFailureTest,
|
|||
class EvalSuccessTest : public testing::TestWithParam<std::filesystem::path> {};
|
||||
|
||||
// Test pattern for files that should evaluate successfully.
|
||||
TEST_P(EvalSuccessTest, Fails) {
|
||||
TEST_P(EvalSuccessTest, Succeeds) {
|
||||
std::shared_ptr<Store> store = std::make_shared<DummyStore>();
|
||||
EvalState state({}, ref<Store>(store));
|
||||
auto path = GetParam();
|
||||
|
|
@ -236,4 +237,53 @@ INSTANTIATE_TEST_SUITE_P(Eval, EvalSuccessTest,
|
|||
testing::ValuesIn(TestFilesFor("eval-okay-")),
|
||||
TestNameFor);
|
||||
|
||||
class BlankStoreTest : public nix::StoreTest {
|
||||
virtual void TestBody() override{};
|
||||
};
|
||||
|
||||
class EvalStoreSuccessTest
|
||||
: public testing::TestWithParam<std::filesystem::path> {
|
||||
public:
|
||||
virtual void TearDown() { store_test_.TearDown(); }
|
||||
|
||||
absl::StatusOr<std::unique_ptr<nix::LocalStore>> OpenTemporaryStore() {
|
||||
return store_test_.OpenTemporaryStore();
|
||||
}
|
||||
|
||||
private:
|
||||
BlankStoreTest store_test_;
|
||||
};
|
||||
|
||||
// Test pattern for files that should evaluate successfully but require a real
|
||||
// store.
|
||||
TEST_P(EvalStoreSuccessTest, Succeeds) {
|
||||
std::unique_ptr<nix::LocalStore> store_ =
|
||||
OpenTemporaryStore().ConsumeValueOrDie();
|
||||
ref<Store> store = ref<Store>(store_.release());
|
||||
EvalState state({}, store);
|
||||
auto path = GetParam();
|
||||
|
||||
Expr* expr = nullptr;
|
||||
ASSERT_NO_THROW(expr = state.parseExprFromFile(GetParam().string()))
|
||||
<< path.stem().string() << ": should parse successfully";
|
||||
|
||||
Value result;
|
||||
|
||||
ASSERT_NO_THROW({
|
||||
state.eval(expr, result);
|
||||
state.forceValueDeep(result);
|
||||
}) << path.stem().string()
|
||||
<< ": should evaluate successfully";
|
||||
|
||||
auto expected = ExpectedOutputFor(path.stem().string());
|
||||
std::ostringstream value_str;
|
||||
value_str << result;
|
||||
|
||||
EXPECT_EQ(expected, value_str.str()) << "evaluator output should match";
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(Eval, EvalStoreSuccessTest,
|
||||
testing::ValuesIn(TestFilesFor("evalstore-okay-")),
|
||||
TestNameFor);
|
||||
|
||||
} // namespace nix::tests
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue