File tree 3 files changed +17
-1
lines changed
examples/rust-flake-project
3 files changed +17
-1
lines changed Original file line number Diff line number Diff line change 8
8
crateName = "rust-flake-project" ;
9
9
10
10
devShellHook = config . settings . shell . hook ;
11
-
11
+ exportTests = true ;
12
12
} ;
13
13
in
14
14
{
Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ Creates a flake for a Rust project.
33
33
- ` generateDocs ` (default=true): Generate Rustdoc
34
34
- ` runTests ` (default=true): Run testsuite using cargo-nextest
35
35
- ` runClippy ` (default=true): Run clippy linter
36
+ - ` exportTests ` (default=false): Build testsuite as standalone executables
36
37
37
38
** Returns:**
38
39
Original file line number Diff line number Diff line change @@ -47,6 +47,8 @@ inputCrane: pkgs:
47
47
extraEnvVars ? null
48
48
# Generate Rustdoc
49
49
, generateDocs ? true
50
+ # Build testsuite as standalone executables
51
+ , exportTests ? false
50
52
# Run testsuite using cargo-nextest
51
53
, runTests ? true
52
54
# Run clippy linter
206
208
inherit doInstallCargoArtifacts ;
207
209
} ) ;
208
210
211
+ } ) // ( optionalAttrs exportTests {
212
+ "${ crateName } -rust-test" = craneLib . buildPackage ( commonArgs // {
213
+ inherit cargoArtifacts ;
214
+ cargoExtraArgs = cargoNextestExtraArgs + " --tests" ;
215
+ nativeBuildInputs = commonArgs . nativeBuildInputs ++ testTools ++ [ pkgs . jq ] ;
216
+ installPhaseCommand = ''
217
+ files=$(cat $cargoBuildLog | jq 'select(.target.kind | . != null and contains(["test"])).executable')
218
+ mkdir -p $out/bin
219
+
220
+ echo $files | xargs -r mv -t $out/bin
221
+ '' ;
222
+ } ) ;
209
223
} ) // {
210
224
"${ crateName } -rust" = craneLib . buildPackage ( commonArgs // {
211
225
inherit cargoArtifacts ;
217
231
"${ crateName } -rust-src" = vendoredSrc ;
218
232
219
233
"${ crateName } -rust-build-env" = buildEnv ;
234
+
220
235
} ;
221
236
222
237
checks =
You can’t perform that action at this time.
0 commit comments