From 5b44ddc7af7a16d32301082317ca66b0563ff91d Mon Sep 17 00:00:00 2001
From: Jean-Paul Calderone <exarkun@twistedmatrix.com>
Date: Thu, 25 Mar 2021 20:03:06 -0400
Subject: [PATCH] minor maintainability improvements to the test

---
 nixos/lib/tests/test_openssl.nix | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/nixos/lib/tests/test_openssl.nix b/nixos/lib/tests/test_openssl.nix
index a651657f..db3a82ec 100644
--- a/nixos/lib/tests/test_openssl.nix
+++ b/nixos/lib/tests/test_openssl.nix
@@ -1,18 +1,30 @@
 openssl:
-{ test_package_version =
-  { expected = "1.1.1k";
-    expr = "${openssl.version}";
+let
+  # This is the version of OpenSSL that we want to see.
+  expected = "1.1.1k";
+in {
+  # Check the packaging version.  It's nice for this to be what we expect
+  # because otherwise things get confusing but this is just the number *we*
+  # (or nixpkgs) puts on the software.
+  test_package_version = {
+    inherit expected;
+    expr = openssl.version;
   };
+
+  # Now check that the version OpenSSL itself reports is the same.
   test_runtime_version_matches =
-  { expected = "${openssl.version}";
+  { inherit expected;
     expr =
       let
+        # Find out what openssl thinks its own version is.
         pkgs = import <nixpkgs> { };
         cmd = "${openssl}/bin/openssl version";
         drv = pkgs.runCommand "version" {} "${cmd} > $out";
         runtime_version = builtins.readFile drv;
         pieces = pkgs.lib.splitString " " runtime_version;
       in
+        # The pieces are like [ "OpenSSL" "1.1.1k" "25" "Mar" "2021" ].  We
+        # don't really care about the date.  Get just the version number.
         builtins.elemAt pieces 1;
   };
 }
-- 
GitLab