about summary refs log tree commit diff
path: root/third_party/nix/src/tests/arbitrary.hh
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2022-05-18T15·39+0200
committerclbot <clbot@tvl.fyi>2022-05-19T14·08+0000
commitd127f9bd0e7b9b2e0df2de8a2227f77c0907468d (patch)
tree68455040d88b8e0c2817601db88ede450873ff8e /third_party/nix/src/tests/arbitrary.hh
parentc85291c602ac666421627d6934ebc6d5be1b93e1 (diff)
chore(3p/nix): unvendor tvix 0.1 r/4098
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 <sternenseemann@systemli.org>
Reviewed-by: lukegb <lukegb@tvl.fyi>
Autosubmit: tazjin <tazjin@tvl.su>
Diffstat (limited to 'third_party/nix/src/tests/arbitrary.hh')
-rw-r--r--third_party/nix/src/tests/arbitrary.hh176
1 files changed, 0 insertions, 176 deletions
diff --git a/third_party/nix/src/tests/arbitrary.hh b/third_party/nix/src/tests/arbitrary.hh
deleted file mode 100644
index 026f8522cf71..000000000000
--- a/third_party/nix/src/tests/arbitrary.hh
+++ /dev/null
@@ -1,176 +0,0 @@
-#pragma once
-
-#include <rapidcheck.h>
-#include <rapidcheck/Gen.h>
-#include <rapidcheck/gen/Arbitrary.h>
-
-#include "libexpr/attr-set.hh"
-#include "libexpr/nixexpr.hh"
-#include "libstore/derivations.hh"
-#include "libutil/hash.hh"
-
-namespace nix::tests {
-static nix::SymbolTable* symbol_table;
-}
-
-namespace rc {
-
-using nix::Derivation;
-using nix::DerivationOutput;
-using nix::Pos;
-using nix::Value;
-
-template <>
-struct Arbitrary<nix::Symbol> {
-  static Gen<nix::Symbol> arbitrary() {
-    return gen::map(gen::arbitrary<std::string>(), [](std::string s) {
-      return nix::tests::symbol_table->Create(s);
-    });
-  }
-};
-
-template <>
-struct Arbitrary<Value> {
-  static Gen<nix::Value> arbitrary() {
-    return gen::build(gen::construct<Value>(),
-                      // TODO(grfn) generalize to more types
-                      gen::set(&Value::type, gen::just(nix::ValueType::tInt)),
-                      gen::set(&Value::integer, gen::arbitrary<int64_t>()));
-  }
-};
-
-template <>
-struct Arbitrary<Value*> {
-  static Gen<nix::Value*> arbitrary() {
-    return gen::apply(
-        [](nix::ValueType typ, int i) {
-          auto ret = new Value();
-          ret->type = typ;
-          ret->integer = i;
-          return ret;
-        },
-        gen::just(nix::ValueType::tInt), gen::arbitrary<int64_t>());
-  }
-};
-
-template <>
-struct Arbitrary<nix::Pos> {
-  static Gen<nix::Pos> arbitrary() {
-    return gen::construct<nix::Pos>(gen::arbitrary<nix::Symbol>(),
-                                    gen::arbitrary<unsigned int>(),
-                                    gen::arbitrary<unsigned int>());
-  }
-};
-
-template <>
-struct Arbitrary<nix::Pos*> {
-  static Gen<nix::Pos*> arbitrary() {
-    return gen::apply(
-        [](unsigned int line, unsigned int column) {
-          return new Pos({}, line, column);
-        },
-        gen::arbitrary<unsigned int>(), gen::arbitrary<unsigned int>());
-  }
-};
-
-template <>
-struct Arbitrary<nix::Attr> {
-  static Gen<nix::Attr> arbitrary() {
-    return gen::construct<nix::Attr>(gen::arbitrary<nix::Symbol>(),
-                                     gen::arbitrary<Value*>(),
-                                     gen::arbitrary<nix::Pos*>());
-  }
-};
-
-template <>
-struct Arbitrary<nix::Bindings> {
-  static Gen<nix::Bindings> arbitrary() {
-    return gen::map(gen::arbitrary<std::vector<nix::Attr>>(), [](auto attrs) {
-      nix::Bindings res;
-      for (const auto& attr : attrs) {
-        res.push_back(attr);
-      }
-      return res;
-    });
-  }
-};
-
-template <class K, class V>
-struct Arbitrary<absl::btree_map<K, V>> {
-  static Gen<absl::btree_map<K, V>> arbitrary() {
-    return gen::map(gen::arbitrary<std::map<K, V>>(), [](std::map<K, V> map) {
-      absl::btree_map<K, V> out_map;
-      out_map.insert(map.begin(), map.end());
-      return out_map;
-    });
-  }
-};
-
-template <>
-struct Arbitrary<nix::Base> {
-  static Gen<nix::Base> arbitrary() {
-    return gen::element(nix::Base16, nix::Base32, nix::Base64);
-  }
-};
-
-template <>
-struct Arbitrary<DerivationOutput> {
-  static Gen<DerivationOutput> arbitrary() {
-    return gen::apply(
-        [](std::string content, std::string path, std::string hash_algo,
-           bool recursive, bool include_algo_in_hash, nix::Base base) {
-          auto hash_type = nix::parseHashType(hash_algo);
-          auto hash = nix::hashString(hash_type, content);
-          return DerivationOutput(
-              path, recursive ? absl::StrCat("r:", hash_algo) : hash_algo,
-              hash.to_string(base, include_algo_in_hash));
-        },
-        gen::arbitrary<std::string>(),
-        gen::map(gen::arbitrary<std::string>(),
-                 [](std::string s) { return absl::StrCat("/", s); }),
-        gen::element<std::string>("md5", "sha1", "sha256", "sha512"),
-        gen::arbitrary<bool>(), gen::arbitrary<bool>(),
-        gen::arbitrary<nix::Base>());
-  }
-};
-
-template <>
-struct Arbitrary<Derivation> {
-  static Gen<Derivation> arbitrary() {
-    auto gen_path = gen::map(gen::arbitrary<std::string>(), [](std::string s) {
-      return absl::StrCat("/", s);
-    });
-
-    return gen::build<Derivation>(
-        gen::set(&nix::BasicDerivation::outputs),
-        gen::set(&nix::BasicDerivation::inputSrcs,
-                 gen::container<nix::PathSet>(gen_path)),
-        gen::set(&nix::BasicDerivation::platform),
-        gen::set(&nix::BasicDerivation::builder, gen_path),
-        gen::set(&nix::BasicDerivation::args),
-        gen::set(&nix::BasicDerivation::env),
-        gen::set(&Derivation::inputDrvs,
-                 gen::container<nix::DerivationInputs>(
-                     gen_path, gen::arbitrary<nix::StringSet>())));
-  }
-};
-
-template <>
-struct Arbitrary<nix::BuildResult::Status> {
-  static Gen<nix::BuildResult::Status> arbitrary() {
-    return gen::element(nix::BuildResult::Status::Built,
-                        nix::BuildResult::Status::Substituted,
-                        nix::BuildResult::Status::AlreadyValid,
-                        nix::BuildResult::Status::PermanentFailure,
-                        nix::BuildResult::Status::InputRejected,
-                        nix::BuildResult::Status::OutputRejected,
-                        nix::BuildResult::Status::TransientFailure,
-                        nix::BuildResult::Status::CachedFailure,
-                        nix::BuildResult::Status::TimedOut,
-                        nix::BuildResult::Status::MiscFailure,
-                        nix::BuildResult::Status::DependencyFailed,
-                        nix::BuildResult::Status::LogLimitExceeded,
-                        nix::BuildResult::Status::NotDeterministic);
-  }
-};
-}  // namespace rc