From cc27324d0226953943f408ce3c69ad7d648e005e Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Sat, 21 Nov 2020 15:26:02 +0100 Subject: chore(tvix): Use StatusOr API available in Abseil's version 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 --- third_party/nix/src/tests/language-tests.cc | 7 ++++--- third_party/nix/src/tests/store-util.hh | 7 +++++-- third_party/nix/src/tests/store_tests.cc | 5 +++-- 3 files changed, 12 insertions(+), 7 deletions(-) (limited to 'third_party/nix/src/tests') diff --git a/third_party/nix/src/tests/language-tests.cc b/third_party/nix/src/tests/language-tests.cc index 189e1ede5c37..46e8c6ea80f7 100644 --- a/third_party/nix/src/tests/language-tests.cc +++ b/third_party/nix/src/tests/language-tests.cc @@ -257,9 +257,10 @@ class EvalStoreSuccessTest // Test pattern for files that should evaluate successfully but require a real // store. TEST_P(EvalStoreSuccessTest, Succeeds) { - std::unique_ptr store_ = - OpenTemporaryStore().ConsumeValueOrDie(); - ref store = ref(store_.release()); + absl::StatusOr> store_ = + OpenTemporaryStore(); + CHECK(store_.ok()) << "failed to open temporary store"; + ref store = ref(store_->release()); EvalState state({}, store); auto path = GetParam(); diff --git a/third_party/nix/src/tests/store-util.hh b/third_party/nix/src/tests/store-util.hh index 170794616b2b..b31bb0edcb8f 100644 --- a/third_party/nix/src/tests/store-util.hh +++ b/third_party/nix/src/tests/store-util.hh @@ -58,10 +58,13 @@ class StoreTest : public ::testing::Test { } absl::StatusOr> OpenTemporaryStore() { - ASSIGN_OR_RETURN(std::filesystem::path storePath, OpenTempDir()); + absl::StatusOr storePath = OpenTempDir(); + if (!storePath.ok()) { + return storePath.status(); + } nix::Store::Params params; - params["root"] = storePath; + params["root"] = *storePath; return std::make_unique(params); } diff --git a/third_party/nix/src/tests/store_tests.cc b/third_party/nix/src/tests/store_tests.cc index 8110e9c337bc..a6ffb715a90f 100644 --- a/third_party/nix/src/tests/store_tests.cc +++ b/third_party/nix/src/tests/store_tests.cc @@ -90,8 +90,9 @@ TEST_F(BinaryCacheStoreTest, BasicErrors) { // ./tests/add.sh TEST_F(StoreTest, AddFileHashes) { - auto store_ = OpenTemporaryStore().ConsumeValueOrDie(); - nix::Store* store = static_cast(store_.get()); + auto store_ = OpenTemporaryStore(); + CHECK(store_.ok()) << "failed to open temporary store"; + nix::Store* store = store_->release(); nix::Path dataPath = NIX_SRC_DIR "/src/tests/lang/data"; std::string dataName = "data"; -- cgit 1.4.1