about summary refs log tree commit diff
path: root/third_party/nix/src
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/nix/src')
-rw-r--r--third_party/nix/src/tests/lang/disabled/eval-okay-context.nix6
-rw-r--r--third_party/nix/src/tests/lang/disabled/eval-okay-search-path.exp (renamed from third_party/nix/src/tests/lang/eval-okay-search-path.exp)0
-rw-r--r--third_party/nix/src/tests/lang/disabled/eval-okay-search-path.flags (renamed from third_party/nix/src/tests/lang/eval-okay-search-path.flags)0
-rw-r--r--third_party/nix/src/tests/lang/disabled/eval-okay-xml.exp (renamed from third_party/nix/src/tests/lang/eval-okay-xml.exp)0
-rw-r--r--third_party/nix/src/tests/lang/eval-okay-context.exp1
-rw-r--r--third_party/nix/src/tests/lang/evalargs-okay-autoargs.nix (renamed from third_party/nix/src/tests/lang/disabled/eval-okay-autoargs.nix)0
-rw-r--r--third_party/nix/src/tests/lang/evalstore-okay-autoargs.exp (renamed from third_party/nix/src/tests/lang/disabled/eval-okay-autoargs.exp)0
-rw-r--r--third_party/nix/src/tests/lang/evalstore-okay-context-introspection.exp (renamed from third_party/nix/src/tests/lang/eval-okay-context-introspection.exp)0
-rw-r--r--third_party/nix/src/tests/lang/evalstore-okay-context-introspection.nix (renamed from third_party/nix/src/tests/lang/disabled/eval-okay-context-introspection.nix)2
-rw-r--r--third_party/nix/src/tests/lang/evalstore-okay-context.exp1
-rw-r--r--third_party/nix/src/tests/lang/evalstore-okay-context.nix6
-rw-r--r--third_party/nix/src/tests/lang/evalstore-okay-toxml.exp (renamed from third_party/nix/src/tests/lang/eval-okay-toxml.exp)0
-rw-r--r--third_party/nix/src/tests/lang/evalstore-okay-toxml.nix (renamed from third_party/nix/src/tests/lang/disabled/eval-okay-toxml.nix)0
-rw-r--r--third_party/nix/src/tests/language-tests.cc52
14 files changed, 59 insertions, 9 deletions
diff --git a/third_party/nix/src/tests/lang/disabled/eval-okay-context.nix b/third_party/nix/src/tests/lang/disabled/eval-okay-context.nix
deleted file mode 100644
index 7b9531cfe9e1..000000000000
--- a/third_party/nix/src/tests/lang/disabled/eval-okay-context.nix
+++ /dev/null
@@ -1,6 +0,0 @@
-let s = "foo ${builtins.substring 33 100 (baseNameOf "${./eval-okay-context.nix}")} bar";
-in
-  if s != "foo eval-okay-context.nix bar"
-  then abort "context not discarded"
-  else builtins.unsafeDiscardStringContext s
-
diff --git a/third_party/nix/src/tests/lang/eval-okay-search-path.exp b/third_party/nix/src/tests/lang/disabled/eval-okay-search-path.exp
index 4519bc406db5..4519bc406db5 100644
--- a/third_party/nix/src/tests/lang/eval-okay-search-path.exp
+++ b/third_party/nix/src/tests/lang/disabled/eval-okay-search-path.exp
diff --git a/third_party/nix/src/tests/lang/eval-okay-search-path.flags b/third_party/nix/src/tests/lang/disabled/eval-okay-search-path.flags
index a28e6821004a..a28e6821004a 100644
--- a/third_party/nix/src/tests/lang/eval-okay-search-path.flags
+++ b/third_party/nix/src/tests/lang/disabled/eval-okay-search-path.flags
diff --git a/third_party/nix/src/tests/lang/eval-okay-xml.exp b/third_party/nix/src/tests/lang/disabled/eval-okay-xml.exp
index 92b75e0b8b17..92b75e0b8b17 100644
--- a/third_party/nix/src/tests/lang/eval-okay-xml.exp
+++ b/third_party/nix/src/tests/lang/disabled/eval-okay-xml.exp
diff --git a/third_party/nix/src/tests/lang/eval-okay-context.exp b/third_party/nix/src/tests/lang/eval-okay-context.exp
deleted file mode 100644
index 2f535bdbc454..000000000000
--- a/third_party/nix/src/tests/lang/eval-okay-context.exp
+++ /dev/null
@@ -1 +0,0 @@
-"foo eval-okay-context.nix bar"
diff --git a/third_party/nix/src/tests/lang/disabled/eval-okay-autoargs.nix b/third_party/nix/src/tests/lang/evalargs-okay-autoargs.nix
index 815f51b1d67a..815f51b1d67a 100644
--- a/third_party/nix/src/tests/lang/disabled/eval-okay-autoargs.nix
+++ b/third_party/nix/src/tests/lang/evalargs-okay-autoargs.nix
diff --git a/third_party/nix/src/tests/lang/disabled/eval-okay-autoargs.exp b/third_party/nix/src/tests/lang/evalstore-okay-autoargs.exp
index 7a8391786a09..7a8391786a09 100644
--- a/third_party/nix/src/tests/lang/disabled/eval-okay-autoargs.exp
+++ b/third_party/nix/src/tests/lang/evalstore-okay-autoargs.exp
diff --git a/third_party/nix/src/tests/lang/eval-okay-context-introspection.exp b/third_party/nix/src/tests/lang/evalstore-okay-context-introspection.exp
index 27ba77ddaf61..27ba77ddaf61 100644
--- a/third_party/nix/src/tests/lang/eval-okay-context-introspection.exp
+++ b/third_party/nix/src/tests/lang/evalstore-okay-context-introspection.exp
diff --git a/third_party/nix/src/tests/lang/disabled/eval-okay-context-introspection.nix b/third_party/nix/src/tests/lang/evalstore-okay-context-introspection.nix
index 43178bd2eef9..d11aad38c726 100644
--- a/third_party/nix/src/tests/lang/disabled/eval-okay-context-introspection.nix
+++ b/third_party/nix/src/tests/lang/evalstore-okay-context-introspection.nix
@@ -6,7 +6,7 @@ let
     outputs = [ "out" "foo" ];
   };
 
-  path = "${./eval-okay-context-introspection.nix}";
+  path = "${./evalstore-okay-context-introspection.nix}";
 
   desired-context = {
     "${builtins.unsafeDiscardStringContext path}" = {
diff --git a/third_party/nix/src/tests/lang/evalstore-okay-context.exp b/third_party/nix/src/tests/lang/evalstore-okay-context.exp
new file mode 100644
index 000000000000..f8088f9e172a
--- /dev/null
+++ b/third_party/nix/src/tests/lang/evalstore-okay-context.exp
@@ -0,0 +1 @@
+"foo evalstore-okay-context.nix bar"
diff --git a/third_party/nix/src/tests/lang/evalstore-okay-context.nix b/third_party/nix/src/tests/lang/evalstore-okay-context.nix
new file mode 100644
index 000000000000..90f82abe1c36
--- /dev/null
+++ b/third_party/nix/src/tests/lang/evalstore-okay-context.nix
@@ -0,0 +1,6 @@
+let s = "foo ${builtins.substring 33 100 (baseNameOf "${./evalstore-okay-context.nix}")} bar";
+in
+  if s != "foo evalstore-okay-context.nix bar"
+  then abort "context not discarded"
+  else builtins.unsafeDiscardStringContext s
+
diff --git a/third_party/nix/src/tests/lang/eval-okay-toxml.exp b/third_party/nix/src/tests/lang/evalstore-okay-toxml.exp
index 828220890ecd..828220890ecd 100644
--- a/third_party/nix/src/tests/lang/eval-okay-toxml.exp
+++ b/third_party/nix/src/tests/lang/evalstore-okay-toxml.exp
diff --git a/third_party/nix/src/tests/lang/disabled/eval-okay-toxml.nix b/third_party/nix/src/tests/lang/evalstore-okay-toxml.nix
index 068c97a6c1b3..068c97a6c1b3 100644
--- a/third_party/nix/src/tests/lang/disabled/eval-okay-toxml.nix
+++ b/third_party/nix/src/tests/lang/evalstore-okay-toxml.nix
diff --git a/third_party/nix/src/tests/language-tests.cc b/third_party/nix/src/tests/language-tests.cc
index 5b0e808d1921..189e1ede5c37 100644
--- a/third_party/nix/src/tests/language-tests.cc
+++ b/third_party/nix/src/tests/language-tests.cc
@@ -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