Skip to content

Commit

Permalink
Revert "move libexpr unit test logic to functional test"
Browse files Browse the repository at this point in the history
This reverts commit 87605c539cdf361b2a416a7e12c1e3e5da85161d.
  • Loading branch information
Ericson2314 committed Jun 23, 2024
1 parent 84654d8 commit 129ed19
Show file tree
Hide file tree
Showing 15 changed files with 54 additions and 29 deletions.
24 changes: 0 additions & 24 deletions tests/functional/derivation-advanced-attributes.sh

This file was deleted.

1 change: 0 additions & 1 deletion tests/functional/local.mk
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ nix_tests = \
eval-store.sh \
why-depends.sh \
derivation-json.sh \
derivation-advanced-attributes.sh \
import-derivation.sh \
nix_path.sh \
case-hack.sh \
Expand Down
50 changes: 50 additions & 0 deletions tests/unit/libexpr/derivation.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#include "gtest/gtest.h"
#include <string>
#include "tests/characterization.hh"
#include "tests/libexpr.hh"
#include "derivations.hh"

namespace nix {

class DerivationTest : public CharacterizationTest, public LibExprTest
{
Path unitTestData = getUnitTestData() + "/derivation";

public:
Path goldenMaster(std::string_view testStem) const override
{
return unitTestData + "/" + testStem;
}
};

#define EXPR_DRV_TEST(NAME, STEM) \
TEST_F(DerivationTest, Derivation_##NAME) \
{ \
writeTest( \
STEM ".drv", \
[&]() -> Derivation { \
Value v = eval(readFile(goldenMaster(STEM ".nix"))); \
Symbol s = state.symbols.create("drvPath"); \
auto attr = v.attrs() -> get(s); \
state.forceValueDeep(*attr->value); \
NixStringContext context; \
auto storePath = state.coerceToStorePath(attr->pos, *attr->value, context, ""); \
\
return store->readDerivation(storePath); \
}, \
[&](const auto & file) { \
auto s = readFile(file); \
return parseDerivation(*store, std::move(s), STEM); \
}, \
[&](const auto & file, const auto & got) { \
auto s = got.unparse(*store, false); \
return writeFile(file, std::move(s)); \
}); \
}

EXPR_DRV_TEST(advancedAttributes, "advanced-attributes");
EXPR_DRV_TEST(advancedAttributes_defaults, "advanced-attributes-defaults");
EXPR_DRV_TEST(advancedAttributes_structuredAttrs, "advanced-attributes-structured-attrs");
EXPR_DRV_TEST(advancedAttributes_structuredAttrs_defaults, "advanced-attributes-structured-attrs-defaults");

}

0 comments on commit 129ed19

Please sign in to comment.