about summary refs log tree commit diff
path: root/third_party/nix/src/libstore
diff options
context:
space:
mode:
authorGriffin Smith <grfn@gws.fyi>2020-08-02T17·28-0400
committerglittershark <grfn@gws.fyi>2020-08-02T20·00+0000
commitcc82d6e3605d428a93cdd7063edc30034816df6f (patch)
tree050c6f8fe315a132e836822f9b3b293b8e613813 /third_party/nix/src/libstore
parent7aebba7531c0e29baba1c8c3725ac3597ad859ee (diff)
test(3p/nix): Add test for derivation parse/serialize r/1548
Add a rapidcheck test covering roundtrip parse and serialize for Nix
derivations. This covers a bug we discovered in ef54f5d which broke this
roundtrip.

Change-Id: I72d140334b5f24f79e82e34f98609c695dbfbf93
Reviewed-on: https://cl.tvl.fyi/c/depot/+/1582
Tested-by: BuildkiteCI
Reviewed-by: kanepyork <rikingcoding@gmail.com>
Diffstat (limited to 'third_party/nix/src/libstore')
-rw-r--r--third_party/nix/src/libstore/derivations.cc2
-rw-r--r--third_party/nix/src/libstore/derivations.hh4
2 files changed, 4 insertions, 2 deletions
diff --git a/third_party/nix/src/libstore/derivations.cc b/third_party/nix/src/libstore/derivations.cc
index 29f929270e..8a50f3c85b 100644
--- a/third_party/nix/src/libstore/derivations.cc
+++ b/third_party/nix/src/libstore/derivations.cc
@@ -144,7 +144,7 @@ static StringSet parseStrings(std::istream& str, bool arePaths) {
   return res;
 }
 
-static Derivation parseDerivation(const std::string& s) {
+Derivation parseDerivation(const std::string& s) {
   Derivation drv;
   istringstream_nocopy str(s);
   expect(str, "Derive([");
diff --git a/third_party/nix/src/libstore/derivations.hh b/third_party/nix/src/libstore/derivations.hh
index 21ef71372e..38877780e0 100644
--- a/third_party/nix/src/libstore/derivations.hh
+++ b/third_party/nix/src/libstore/derivations.hh
@@ -16,10 +16,10 @@ const std::string drvExtension = ".drv";
 
 struct DerivationOutput {
   Path path;
+  // TODO(grfn): make these two fields a Hash
   std::string hashAlgo; /* hash used for expected hash computation */
   std::string hash;     /* expected hash, may be null */
   DerivationOutput() {}
-  // TODO(grfn): Make explicit
   DerivationOutput(Path path, std::string hashAlgo, std::string hash) {
     this->path = path;
     this->hashAlgo = hashAlgo;
@@ -92,6 +92,8 @@ Path writeDerivation(const ref<Store>& store, const Derivation& drv,
 /* Read a derivation from a file. */
 Derivation readDerivation(const Path& drvPath);
 
+Derivation parseDerivation(const std::string& s);
+
 /* Check whether a file name ends with the extension for
    derivations. */
 bool isDerivation(const std::string& fileName);