about summary refs log tree commit diff
path: root/users/Profpatsch/writers
diff options
context:
space:
mode:
authorProfpatsch <mail@profpatsch.de>2021-04-04T11·05+0200
committerProfpatsch <mail@profpatsch.de>2021-04-04T15·16+0000
commite7c78570ed66cd753add2664b7545d234c947b84 (patch)
tree9ffe37708d7d8e5c45db622721f5f9adfe2f4245 /users/Profpatsch/writers
parent5319465f606a82629d41dfb96d73069e6735285b (diff)
feat(users/Profpatsch/writers): make testing default for rustSimple r/2434
This way we don’t have to explicitely wrap the rust crate with a
`testRustSimple`, but it will be done automatically, unless `doCheck`
is set to `false`.

Change-Id: I32a81821eeff620e7da57332b0873495bb85a843
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2841
Tested-by: BuildkiteCI
Reviewed-by: Profpatsch <mail@profpatsch.de>
Reviewed-by: sterni <sternenseemann@systemli.org>
Diffstat (limited to 'users/Profpatsch/writers')
-rw-r--r--users/Profpatsch/writers/default.nix15
-rw-r--r--users/Profpatsch/writers/tests/default.nix5
2 files changed, 12 insertions, 8 deletions
diff --git a/users/Profpatsch/writers/default.nix b/users/Profpatsch/writers/default.nix
index ee3ac7bda7..3cb105b5ed 100644
--- a/users/Profpatsch/writers/default.nix
+++ b/users/Profpatsch/writers/default.nix
@@ -78,8 +78,11 @@ let
   rustSimpleBin = {
     name,
     dependencies ? [],
+    doCheck ? true,
     ...
-  }@args: src: pkgs.buildRustCrate ({
+  }@args: src:
+    (if doCheck then testRustSimple else pkgs.lib.id)
+    (pkgs.buildRustCrate ({
       pname = name;
       version = "1.0.0";
       crateName = name;
@@ -93,13 +96,16 @@ let
         cp "$srcPath" $out/src/bin/${name}.rs
         find $out
       '';
-    } // args);
+    } // args));
 
   rustSimpleLib = {
     name,
     dependencies ? [],
+    doCheck ? true,
     ...
-  }@args: src: pkgs.buildRustCrate ({
+  }@args: src:
+    (if doCheck then testRustSimple else pkgs.lib.id)
+    (pkgs.buildRustCrate ({
       pname = name;
       version = "1.0.0";
       crateName = name;
@@ -112,7 +118,7 @@ let
         cp "$srcPath" $out/src/lib.rs
         find $out
       '';
-    } // args);
+    } // args));
 
   /* Takes a `buildRustCrate` derivation as an input,
     * builds it with `{ buildTests = true; }` and runs
@@ -146,6 +152,5 @@ in {
     rustSimple
     rustSimpleBin
     rustSimpleLib
-    testRustSimple
     ;
 }
diff --git a/users/Profpatsch/writers/tests/default.nix b/users/Profpatsch/writers/tests/default.nix
index a16f5fa1f9..4b28792f75 100644
--- a/users/Profpatsch/writers/tests/default.nix
+++ b/users/Profpatsch/writers/tests/default.nix
@@ -4,7 +4,6 @@ let
   inherit (depot.users.Profpatsch.writers)
     python3Lib
     python3
-    testRustSimple
     rustSimple
     rustSimpleLib
     rustSimpleBin
@@ -46,7 +45,7 @@ let
   '');
 
 
-  rustTransitiveLib = testRustSimple (rustSimpleLib {
+  rustTransitiveLib = rustSimpleLib {
     name = "transitive";
   } ''
     pub fn transitive(s: &str) -> String {
@@ -64,7 +63,7 @@ let
         assert_eq!(transitive("foo").as_str(), "foo 1 2 3")
       }
     }
-  '');
+  '';
 
   rustTestLib = rustSimpleLib {
     name = "test_lib";