From d127f9bd0e7b9b2e0df2de8a2227f77c0907468d Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Wed, 18 May 2022 17:39:39 +0200 Subject: chore(3p/nix): unvendor tvix 0.1 Nothing is using this now, and we'll likely never pick this up again, but we learned a lot in the process. Every now and then this breaks in some bizarre way on channel bumps and it's just a waste of time to maintain that. Change-Id: Idcf2f5acd4ca7070ce18d7149cbfc0d967dc0a44 Reviewed-on: https://cl.tvl.fyi/c/depot/+/5632 Tested-by: BuildkiteCI Reviewed-by: sterni Reviewed-by: lukegb Autosubmit: tazjin --- third_party/nix/src/tests/value-to-json.cc | 257 ----------------------------- 1 file changed, 257 deletions(-) delete mode 100644 third_party/nix/src/tests/value-to-json.cc (limited to 'third_party/nix/src/tests/value-to-json.cc') diff --git a/third_party/nix/src/tests/value-to-json.cc b/third_party/nix/src/tests/value-to-json.cc deleted file mode 100644 index 45427425306f..000000000000 --- a/third_party/nix/src/tests/value-to-json.cc +++ /dev/null @@ -1,257 +0,0 @@ -#include "libexpr/value-to-json.hh" - -#include -#include - -#include - -#include "libexpr/value-to-xml.hh" -#include "libexpr/value.hh" -#include "libstore/store-api.hh" -#include "tests/dummy-store.hh" - -class ValueTest : public ::testing::Test { - protected: - static void SetUpTestCase() { nix::expr::InitGC(); } - - static void TearDownTestCase() {} -}; - -class JSONValueTest : public ValueTest {}; -class XMLValueTest : public ValueTest {}; - -namespace nix { - -using nix::tests::DummyStore; - -TEST_F(JSONValueTest, null) { - std::stringstream ss; - Value v; - PathSet ps; - std::shared_ptr store = std::make_shared(); - EvalState s({}, ref(store)); - - mkNull(v); - printValueAsJSON(s, true, v, ss, ps); - ASSERT_EQ(ss.str(), "null"); -} - -TEST_F(JSONValueTest, BoolFalse) { - std::stringstream ss; - auto store = std::make_shared(); - EvalState s({"."}, ref(store)); - Value v; - PathSet ps; - - mkBool(v, false); - printValueAsJSON(s, true, v, ss, ps); - ASSERT_EQ(ss.str(), "false"); -} - -TEST_F(JSONValueTest, BoolTrue) { - std::stringstream ss; - auto store = std::make_shared(); - EvalState s({"."}, ref(store)); - Value v; - PathSet ps; - - mkBool(v, true); - printValueAsJSON(s, true, v, ss, ps); - ASSERT_EQ(ss.str(), "true"); -} - -TEST_F(JSONValueTest, IntPositive) { - std::stringstream ss; - auto store = std::make_shared(); - EvalState s({"."}, ref(store)); - Value v; - PathSet ps; - - mkInt(v, 100); - printValueAsJSON(s, true, v, ss, ps); - ASSERT_EQ(ss.str(), "100"); -} - -TEST_F(JSONValueTest, IntNegative) { - std::stringstream ss; - auto store = std::make_shared(); - EvalState s({"."}, ref(store)); - Value v; - PathSet ps; - - mkInt(v, -100); - printValueAsJSON(s, true, v, ss, ps); - ASSERT_EQ(ss.str(), "-100"); -} - -TEST_F(JSONValueTest, String) { - std::stringstream ss; - auto store = std::make_shared(); - EvalState s({"."}, ref(store)); - Value v; - PathSet ps; - - mkString(v, "test"); - printValueAsJSON(s, true, v, ss, ps); - ASSERT_EQ(ss.str(), "\"test\""); -} - -TEST_F(JSONValueTest, StringQuotes) { - std::stringstream ss; - auto store = std::make_shared(); - EvalState s({"."}, ref(store)); - Value v; - PathSet ps; - - mkString(v, "test\""); - printValueAsJSON(s, true, v, ss, ps); - ASSERT_EQ(ss.str(), "\"test\\\"\""); -} - -TEST_F(JSONValueTest, Path) { - std::stringstream ss; - auto store = std::make_shared(); - EvalState s({"."}, ref(store)); - Value v; - PathSet ps; - - mkPathNoCopy(v, "/exists-for-tests"); - printValueAsJSON(s, true, v, ss, ps); - ASSERT_EQ(ss.str(), "\"/nix/store/g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-x\""); -} - -TEST_F(JSONValueTest, PathNoCopy) { - std::stringstream ss; - auto store = std::make_shared(); - EvalState s({"."}, ref(store)); - Value v; - PathSet ps; - - mkPathNoCopy(v, "/exists-for-tests"); - printValueAsJSON(s, true, v, ss, ps); - ASSERT_EQ(ss.str(), "\"/nix/store/g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-x\""); -} - -/* - * Value to XMl tests - */ - -#define XML(v) \ - ("\n\n" v "\n\n") - -TEST_F(XMLValueTest, null) { - std::stringstream ss; - Value v; - PathSet ps; - auto store = std::make_shared(); - EvalState s({}, ref(store)); - - mkNull(v); - printValueAsXML(s, true, true, v, ss, ps); - ASSERT_EQ(ss.str(), XML(" ")); -} - -TEST_F(XMLValueTest, BoolFalse) { - std::stringstream ss; - auto store = std::make_shared(); - EvalState s({"."}, ref(store)); - Value v; - PathSet ps; - - mkBool(v, false); - printValueAsXML(s, true, true, v, ss, ps); - ASSERT_EQ(ss.str(), XML(" ")); -} - -TEST_F(XMLValueTest, BoolTrue) { - std::stringstream ss; - auto store = std::make_shared(); - EvalState s({"."}, ref(store)); - Value v; - PathSet ps; - - mkBool(v, true); - printValueAsXML(s, true, true, v, ss, ps); - ASSERT_EQ(ss.str(), XML(" ")); -} - -TEST_F(XMLValueTest, IntPositive) { - std::stringstream ss; - auto store = std::make_shared(); - EvalState s({"."}, ref(store)); - Value v; - PathSet ps; - - mkInt(v, 100); - printValueAsXML(s, true, true, v, ss, ps); - ASSERT_EQ(ss.str(), XML(" ")); -} - -TEST_F(XMLValueTest, IntNegative) { - std::stringstream ss; - auto store = std::make_shared(); - EvalState s({"."}, ref(store)); - Value v; - PathSet ps; - - mkInt(v, -100); - printValueAsXML(s, true, true, v, ss, ps); - ASSERT_EQ(ss.str(), XML(" ")); -} - -TEST_F(XMLValueTest, String) { - std::stringstream ss; - auto store = std::make_shared(); - EvalState s({"."}, ref(store)); - Value v; - PathSet ps; - - mkString(v, "test-value"); - printValueAsXML(s, true, true, v, ss, ps); - ASSERT_EQ(ss.str(), XML(" ")); -} - -TEST_F(XMLValueTest, StringQuotes) { - std::stringstream ss; - auto store = std::make_shared(); - EvalState s({"."}, ref(store)); - Value v; - PathSet ps; - - mkString(v, "test-value\""); - printValueAsXML(s, true, true, v, ss, ps); - ASSERT_EQ(ss.str(), XML(" ")); -} - -/* - * FIXME: This function returns the original input path while the JSON version - * of the same actually touches the store to create a /nix/store path. - */ -TEST_F(XMLValueTest, Path) { - std::stringstream ss; - auto store = std::make_shared(); - EvalState s({"."}, ref(store)); - Value v; - PathSet ps; - - mkPath(v, "some-path"); - printValueAsXML(s, true, true, v, ss, ps); - ASSERT_EQ(ss.str(), XML(" ")); -} - -/* - * FIXME: This function returns the original input path while the JSON version - * of the same actually touches the store to create a /nix/store path. - */ -TEST_F(XMLValueTest, PathNoCopy) { - std::stringstream ss; - auto store = std::make_shared(); - EvalState s({"."}, ref(store)); - Value v; - PathSet ps; - - mkPathNoCopy(v, "some-other-path"); - printValueAsXML(s, true, true, v, ss, ps); - ASSERT_EQ(ss.str(), XML(" ")); -} -} // namespace nix -- cgit 1.4.1