about summary refs log tree commit diff
path: root/third_party/nix/src/tests (follow)
AgeCommit message (Collapse)AuthorFilesLines
2020-11-28 r/1948 refactor(tvix): Centralize arbitrary definitionsGriffin Smith4-175/+180
To make it easier for future tests to use the arbitrary specialisations we've defined for some nix types, centralize them all in a single arbitrary.hh header file. Change-Id: I767f27949cfe7ec55c79901f7d7aa538d2f98c6b Reviewed-on: https://cl.tvl.fyi/c/depot/+/2182 Tested-by: BuildkiteCI Reviewed-by: kanepyork <rikingcoding@gmail.com>
2020-11-28 r/1947 fix(tvix): Add missing break;s to BuildResult::FromProtoGriffin Smith2-0/+59
Add missing break statements to the big switch block in BuildResult::FromProto, and cover the whole thing with a rapidcheck round-trip test. Change-Id: I7a07ca398cc5f02ca4fd8e6256fd563c6f3aea9d Reviewed-on: https://cl.tvl.fyi/c/depot/+/2178 Tested-by: BuildkiteCI Reviewed-by: kanepyork <rikingcoding@gmail.com>
2020-11-28 r/1946 feat(tvix): Thread a log sink through calls to buildDerivationGriffin Smith1-1/+2
Similarly to how we did for buildPaths, add a std::ostream& log_sink parameter to the build_derivation method on Store, and pass it std::cerr when called at the top level by nix commands - most notably, the build-remote hook binary, so that we get build logs when using tvix as a remote builder. Change-Id: I0f8f729ba8429d4838a0a135a5c2ac1e1a95d575 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2176 Tested-by: BuildkiteCI Reviewed-by: andi <andi@notmuch.email> Reviewed-by: kanepyork <rikingcoding@gmail.com>
2020-11-21 r/1888 chore(tvix): Use StatusOr API available in Abseil's versionVincent Ambo3-7/+12
The Abseil version of `StatusOr` does not come with the status macros or the `Consume*` family of functions. This change modifies the existing code to use the common denominator of the API that is available between Abseil's own implementation of `StatusOr` and the one from Tensorflow that we are currently using. Change-Id: I5c37f68636a1fd54d153f95d7303ab8644abb774
2020-11-19 r/1886 fix(tvix): Use copy constructor to add strings to protosGriffin Smith1-0/+28
Passing a string directly to add_paths like this causes the proto class to take ownership over the string, meaning when it is destructed it will *explicitly* free the string. When the string's actual owner (the derivation struct) then goes out of scope it'll get freed again, causing a double-free. This fixes that to instead use the copy constructor to assign to a pointer to a new path, and covers the whole to_proto method with a rapidcheck test. Fixes: b/64 Change-Id: I84235bed9104ff430a0acf686d4a96f1e2e9a897 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2106 Reviewed-by: tazjin <mail@tazj.in> Tested-by: BuildkiteCI
2020-08-18 r/1673 feat(tvix): Re-enable language tests that needed a storeKane York14-9/+59
Now that we have access to a store in tests, we can enable the tests that needed a store. Additionally, move the expected output files for disabled tests into the disabled folder. Change-Id: I2492d49d43b93c7c9b0463e4d3d2855a5a51365d Reviewed-on: https://cl.tvl.fyi/c/depot/+/1758 Tested-by: BuildkiteCI Reviewed-by: glittershark <grfn@gws.fyi>
2020-08-18 r/1672 chore(tvix/tests): port upstream add.sh testKane York1-0/+30
Change-Id: I5151d142d6b2b7f1df37b170b0160b8f77a89120 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1755 Tested-by: BuildkiteCI Reviewed-by: glittershark <grfn@gws.fyi>
2020-08-18 r/1671 chore(tvix/tests): Add OpenTemporaryStore() helperKane York2-7/+74
Change-Id: Ia655175c255f9cf5a47e4e7a20373a4ba4315ed9 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1753 Tested-by: BuildkiteCI Reviewed-by: glittershark <grfn@gws.fyi>
2020-08-17 r/1658 refactor(tvix): always pass Bindings by ptr, use shared/unique_ptrKane York1-17/+13
Value now carries a shared_ptr<Bindings>, and all Bindings constructors return a unique_ptr<Bindings>. The test that wanted to compare two Bindings by putting them into Values has been modified to use the new Equal() method on Bindings (extracted from EvalState). Change-Id: I8dfb60e65fdabb717e3b3e5d56d5b3fc82f70883 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1744 Tested-by: BuildkiteCI Reviewed-by: glittershark <grfn@gws.fyi> Reviewed-by: tazjin <mail@tazj.in>
2020-08-15 r/1655 fix(tvix): Ensure prim_sort actually uses the right outlistVincent Ambo1-0/+0
Previously the outlist would not be used, and it would sort god knows what in the out value. This was probably introduced by the std::vector refactoring, and the language test for builtins.sort was disabled. Whatever reason there was for disabling it seems to be gone, so we're re-enabling it. Change-Id: I98941c2cad78df58ff7bea1ece3aaa4133e94bf8 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1757 Reviewed-by: kanepyork <rikingcoding@gmail.com> Tested-by: BuildkiteCI
2020-08-15 r/1654 feat(tvix/tests): add gtest matchers for absl::StatusKane York1-0/+83
This allows you to write EXPECT_OK(statusor), as well as EXPECT_THAT(status, IsStatusCode(StatusCode::kInvalidArgument). Change-Id: I53bed694d812c501eb305ed4ddb358e1f9a68277 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1704 Tested-by: BuildkiteCI Reviewed-by: glittershark <grfn@gws.fyi>
2020-08-14 r/1646 refactor(tvix): completely remove boehm gcKane York1-3/+2
We have decided that leaking memory is a better fate than random, non-debuggable memory corruption. Future CLs will begin changing various fields to std::unique_ptr and std::shared_ptr. It turns out that disabling the GC does not have disasterous impact. The Nix evaluator only runs on the client CLI, never in any long- running process. Even the REPL does not leak too badly under this change, because it uses one EvalState for the duration of the REPL. Building an explicitly tracing garbage collector is likely in the future of this project, but that giant amount of work cannot be done under a nix evaluator that is constantly crashing. We need to restore development velocity here, and this is the best way we've figured out to do it. Change-Id: I2fcda8fcee853c15a9a5e22eca7c5a784bc2bf76 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1720 Reviewed-by: glittershark <grfn@gws.fyi> Reviewed-by: tazjin <mail@tazj.in> Tested-by: BuildkiteCI
2020-08-09 r/1627 test(tvix): Cover scanForReferences in a testGriffin Smith2-0/+84
Aded a few test cases covering the scanForReferences function, which had been accidentally broken in 976a36c (which is now partially-reverted). As part of this, since the test needed to generate hashes for store paths, the logic in MakeStorePath to compress a sha256 hash down to 20 bytes and convert it to base32 has been extracted to a member function on the Hash class. Fixes: #34 Change-Id: Ie2d914688a80f42d0234d351a7cc0714fd15709e Reviewed-on: https://cl.tvl.fyi/c/depot/+/1698 Tested-by: BuildkiteCI Reviewed-by: kanepyork <rikingcoding@gmail.com>
2020-08-06 r/1613 fix(3p/nix): Use SkipEmpty in all calls to absl::StrSplitKane York1-1/+2
The behavior to return a list containing a single empty string when provided an empty string is a behavior that absl inherited from legacy code. However, the behavior expected by legacy code in Nix is the behavior provided by the SkipEmpty option. Switch all calls to use SkipEmpty, except for the call already using SkipWhitespace. See also commit 26a59482d2427f640893517f1b24dd650a5bd5da, with the partly-prophetic message: "there may be other places we need to fix this as well." Change-Id: I6e94856a12cfb1b7e4a3b4e221769ed446648861 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1687 Tested-by: BuildkiteCI Reviewed-by: glittershark <grfn@gws.fyi>
2020-08-06 r/1610 refactor(tvix): Use absl::btree_map for DerivationOutputsVincent Ambo2-0/+12
This container implementation is much faster than std::map. We have stuck to an ordered container because it's unclear whether the accesses of this field (of which there are *many*) are actually ordering dependent. Also includes an Arbitrary implementation for absl::btree_map (for any K, V that are also Arbitrary). Change-Id: I04f58ca0ce32b9ae1759313b01508b0e44bae793 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1683 Reviewed-by: glittershark <grfn@gws.fyi> Tested-by: BuildkiteCI
2020-08-05 r/1596 feat(3p/nix): add tests for BinaryCacheStoreKane York2-0/+106
These tests are in preparation for factoring the Store away from libutil's Callback to absl::StatusOr. They use the newly added MockBinaryCacheStore. Updates: #25 Change-Id: I30c207589ec38254806ebc9a983f35668e353ae9 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1595 Tested-by: BuildkiteCI Reviewed-by: glittershark <grfn@gws.fyi>
2020-08-03 r/1571 fix(3p/nix): Fix parseDrvPathWithOutputsGriffin Smith1-0/+30
At some point the behavior of this function got changed as part of our cleanup - this fixes it to behave the way the rest of the codebase expects (and how it is documented in the header) and covers it with a few tests. Change-Id: Id4c91232968e73489cd866fb4a2a84bcf20d875e Reviewed-on: https://cl.tvl.fyi/c/depot/+/1629 Tested-by: BuildkiteCI Reviewed-by: tazjin <mail@tazj.in>
2020-08-03 r/1557 refactor(3p/nix): Only initialise garbage-collector where neededVincent Ambo3-3/+3
Only libexpr depends on the garbage collector, specifically only instantiations of EvalState actually require the GC to be initialised. Rather than always starting it for the whole program, even if it is not needed, this change moves the GC initialisation into libexpr, guarded by absl::call_once. This should make it possible to run the nix daemon without the garbage collector interfering, granted that things are correcty separated and the daemon does not actually invoke the evaluator. Based on my investigation so far, the daemon logic itself does not require libexpr to be present at all - so I think it is safe - but the current monobinary might have some tricks up its sleeve that will cause problems for us. We can deal with those if they arise. Relates to https://b.tvl.fyi/issues/30 Change-Id: I61c745f96420c02e089bd3c362ac3ccb117d3073 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1584 Tested-by: BuildkiteCI Reviewed-by: edef <edef@edef.eu> Reviewed-by: kanepyork <rikingcoding@gmail.com>
2020-08-02 r/1548 test(3p/nix): Add test for derivation parse/serializeGriffin Smith2-0/+117
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>
2020-08-01 r/1534 fix(3p/nix): revert "apply all clang-tidy fixes"Kane York3-25/+25
This reverts commit ef54f5da9fa30b5c302f2a49595ee5d041f9706a. Resolved conflicts: third_party/nix/src/libexpr/eval.cc third_party/nix/src/libstore/builtins/fetchurl.cc third_party/nix/src/libstore/references.cc third_party/nix/src/libutil/hash.cc third_party/nix/src/nix-daemon/nix-daemon.cc Change-Id: Ib9cf6e96a79a23bde3983579ced3f92e530cb011 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1547 Reviewed-by: glittershark <grfn@gws.fyi> Tested-by: BuildkiteCI
2020-08-01 r/1514 fix(3p/nix/hash): initialize HashSink.ctxKane York1-0/+18
Fixup for CL 1492 (addcba11b05500ba28ade309de6bd53f8153a6c4) Additionally, add a test to verify functionality of HashSink. Change-Id: I2a74b925a1b93ed4d3add29021d759c93e813424 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1507 Tested-by: BuildkiteCI Reviewed-by: glittershark <grfn@gws.fyi>
2020-07-28 r/1504 fix(3p/nix/hash): provide a Status-returning constructorKane York1-1/+41
Additionally, add IsValidBase16() to restore the behavior of rejecting invalid base16, which absl's HexStringToBytes does not do. Change-Id: I777a36f5dc787aa54a2aa316d6728f68da129768 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1484 Tested-by: BuildkiteCI Reviewed-by: tazjin <mail@tazj.in>
2020-07-28 r/1499 chore(3p/nix/hash): add decoding testsKane York1-0/+19
Change-Id: Ifbeaf1822fa920f929482510ee79a5b24d7976ae Reviewed-on: https://cl.tvl.fyi/c/depot/+/1485 Tested-by: BuildkiteCI Reviewed-by: tazjin <mail@tazj.in>
2020-07-27 r/1495 fix(3p/nix): apply all clang-tidy fixesKane York3-25/+25
Change-Id: I265e763393422ee1881653527c91024458060825 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1432 Tested-by: BuildkiteCI Reviewed-by: tazjin <mail@tazj.in>
2020-07-25 r/1462 refactor(3p/nix): Remove custom base64 implementationGriffin Smith2-0/+32
Replace the custom, rather questionable base64 implementation with absl::Base64{Une,E}scape. To make sure that the custom implementation was doing the same thing I've also added a test covering nix::Hash::to_string, which was one function that used it - the test passed prior to the replacement, and continued to pass afterwards. The previous base64Decode function threw an exception on failure - to avoid going too far down the rabbit hole I've replicated that functionality at all call sites, but this should be replaced with more sensible error handling such as StatusOr eventually. Also, before this change: ❯ nix eval -f . users.tazjin.emacs.outPath "/nix/store/g6ri2q8nra96ix20bcsc734r1yyaylb1-tazjins-emacs" And after: ❯ ./result/bin/nix eval -f . users.tazjin.emacs.outPath "/nix/store/g6ri2q8nra96ix20bcsc734r1yyaylb1-tazjins-emacs" Change-Id: Id292ffbb82fe808f3f1b34670afbe7b8c13ad615 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1385 Reviewed-by: tazjin <mail@tazj.in> Tested-by: BuildkiteCI
2020-07-24 r/1451 fix(3p/nix): fix more clang-tidy warningsKane York1-3/+3
Change-Id: I1e8a4852ffa450c552a4cdfc709554799854934c Reviewed-on: https://cl.tvl.fyi/c/depot/+/1416 Tested-by: BuildkiteCI Reviewed-by: glittershark <grfn@gws.fyi>
2020-07-19 r/1403 fix(3p/nix): Fix all remaining compiler warningsVincent Ambo1-1/+1
This compiles under `-Wall -Werror`. The largest chunk of this change is `final` qualifiers for the various Nix CLI command structs, which inherit from a Command class that has more virtual functions than are implemented by each command. Change-Id: I0925e6e1a39013f026773db5816e4a77d50f3b4a Reviewed-on: https://cl.tvl.fyi/c/depot/+/1294 Tested-by: BuildkiteCI Reviewed-by: isomer <isomer@tvl.fyi> Reviewed-by: kanepyork <rikingcoding@gmail.com>
2020-07-19 r/1399 chore(3p/nix): Enable clang-format check in derivation buildVincent Ambo1-1/+0
This is the easiest way to get the checks up and running for now, but we will probably want to separate out things like this into a separate build step in the future. Change-Id: I8e1a1095aef09b1eee97abad5b6240bc64d14b8c Reviewed-on: https://cl.tvl.fyi/c/depot/+/1287 Tested-by: BuildkiteCI Reviewed-by: glittershark <grfn@gws.fyi>
2020-07-19 r/1398 test(3p/nix): Enable output comparison for evaluator success testsVincent Ambo15-364/+35
Enables loading of the expected output of evaluator tests from the corresponding .exp files, and checks that the output matches. This again leaves some tests behind in the disabled folder, but we now have almost the entire suite up and running so I can get around to cleaning up the disabled ones. Other note: Some tests had XML output, despite not being related to XML testing at all - I'm not sure why they chose to do this, but have converted those test outputs to normal Nix instead. We have a separate test suite for JSON & XML serialisation already, which was contributed by andi-. Change-Id: Id7c42c836edfec4c22db9d893e35489f3e6dd559 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1285 Tested-by: BuildkiteCI Reviewed-by: isomer <isomer@tvl.fyi> Reviewed-by: glittershark <grfn@gws.fyi>
2020-07-19 r/1397 test(3p/nix): Partially enable evaluator success testsVincent Ambo7-0/+28
Enables the `eval-okay-` test suite, with some caveats: * The output is not yet checked against the expected value, so the tests only check that pure evaluation succeeds * A handful of tests have been disabled as they are causing failures that may be related to the DummyStore implementation. Both of these will be addressed in followup commits, but there is already some value in having the pure evaluation tests pass. Change-Id: I62236c95ebffb06dc64a45455a8ee04344c400b7 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1284 Tested-by: BuildkiteCI Reviewed-by: isomer <isomer@tvl.fyi> Reviewed-by: glittershark <grfn@gws.fyi>
2020-07-19 r/1395 test(3p/nix): Add property tests for attribute setGriffin Smith2-0/+169
Add a set of property tests for the attribute set (Bindings) class checking that the Merge operation satisfies the monoid laws. This will hopefully become useful to make sure we're not breaking the language semantics as we work towards optimizing or replacing the implementation, but also serves as a test bed for adding rapidcheck-based property tests to the codebase. Change-Id: I1b4b7b6503d08d80c1c5a8f9408fd4b787d00e8e Reviewed-on: https://cl.tvl.fyi/c/depot/+/1283 Reviewed-by: isomer <isomer@tvl.fyi> Tested-by: BuildkiteCI
2020-07-19 r/1390 test(3p/nix): Port language test suite to GoogletestVincent Ambo3-0/+200
This moves the language test suite into Googletest by constructing parameterised tests out of the same language snippets used for the previous lang.sh evaluation. So far this includes support for about 3/4 of all tests, specifically: * all parser success/failure tests * all evaluator failure tests The evaluator success tests will be implemented in a subsequent commit, because the output comparison contains a whole bunch of additional logic that I did not want to cram in here. Change-Id: Icec9f368366cdbaa53b4c7e4472b8b6e8dd72eba Reviewed-on: https://cl.tvl.fyi/c/depot/+/1278 Reviewed-by: glittershark <grfn@gws.fyi> Reviewed-by: isomer <isomer@tvl.fyi> Tested-by: BuildkiteCI
2020-07-19 r/1389 fix(3p/nix/tests): Fail DummyStore::addToStore on non-existent srcPathVincent Ambo2-3/+8
Unfortunately, to guarantee correct behaviour of some evaluation (!) tests, addToStore needs to actually check whether passed in source files exist and fail appropriately. There is a chance that the dependency on this behaviour is actually a bug in the upstream test suite, but my attempts at finding out more about this from, say, the git history have so far been unsuccessful. Change-Id: I311999ea28fcedf5da13a4e627b1c1c8e4e59cbd Reviewed-on: https://cl.tvl.fyi/c/depot/+/1276 Reviewed-by: isomer <isomer@tvl.fyi> Reviewed-by: glittershark <grfn@gws.fyi> Tested-by: BuildkiteCI
2020-07-19 r/1387 chore(3p/nix/tests): Move language test files to src/testsVincent Ambo236-0/+2151
These files will be integrated into the evaluator unit tests instead of running separately via a shell script. Change-Id: I1d229e73b1d862777f5108c86891689900edefbe Reviewed-on: https://cl.tvl.fyi/c/depot/+/1275 Tested-by: BuildkiteCI Reviewed-by: Kane York <rikingcoding@gmail.com> Reviewed-by: isomer <isomer@tvl.fyi>
2020-07-18 r/1378 refactor(3p/nix/tests): Move DummyStore into a separate fileVincent Ambo2-33/+44
This store implementation is required in all unit tests that use the evaluator. Change-Id: I1cfe8cecab8722cd66dc803747821a2be2b2619f Reviewed-on: https://cl.tvl.fyi/c/depot/+/1269 Tested-by: BuildkiteCI Reviewed-by: glittershark <grfn@gws.fyi>
2020-07-18 r/1369 test(3p/nix): Set up scaffolding & fix up tests for value-to-{json|xml}Vincent Ambo2-45/+57
Configures the CMake build to load & run the GoogleTest tests. I (grfn) also updated this to get the tests running as part of the nix derivation, which required defining our own manual configurePhase and installCheckPhase, rather than depending on the one provided by stdenv. Not doing this would cause cmake to attempt to *run* the tests as part of the buildPhase, which wouldn't work because the dynamic libraries hadn't been put into a place where the test executables knew where to find them. We're not sure *why* this fixes it, and for some reason fixing this also breaks the automatic behavior of nixpkgs of passing -j$NIX_BUILD_CORES -l$NIX_BUILD_CORES to make, but that's eaasy enough to fix manually in a preBuild Paired-With: Griffin Smith <grfn@gws.fyi> Change-Id: I79d61854a3ff47301cdce8a40c76820a97bdf901 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1240 Tested-by: BuildkiteCI Reviewed-by: glittershark <grfn@gws.fyi>
2020-07-18 r/1368 test(3p/nix/libexpr): add json/xml testsAndreas Rammhold1-0/+287
Backported from: https://github.com/andir/nix/commit/c1371b6fbb91caf53ebc94d3ae0250dbe7eb7eae Change-Id: Ida326cf1567081a56d747c4a72f036f55cfdea37 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1239 Tested-by: BuildkiteCI Reviewed-by: Kane York <rikingcoding@gmail.com>