File: trycmd.nix

package info (click to toggle)
rust-eza 0.23.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,412 kB
  • sloc: makefile: 14
file content (102 lines) | stat: -rw-r--r-- 2,797 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# SPDX-FileCopyrightText: 2024 Christina Sørensen
# SPDX-License-Identifier: EUPL-1.2
{
  pkgs,
  naersk',
  buildInputs,
  ...
}:

{
  trycmd = naersk'.buildPackage {
    src = ../.;
    mode = "test";
    doCheck = true;
    # No reason to wait for release build
    release = false;
    # buildPhase files differ between dep and main phase
    singleStep = true;
    # generate testing files
    buildPhase = ''
      bash devtools/dir-generator.sh tests/test_dir && echo "Dir generated"
      bash devtools/generate-timestamp-test-dir.sh tests/timestamp_test_dir
    '';
    cargoTestOptions = opts: opts ++ [ "--features nix" ];
    inherit buildInputs;
    nativeBuildInputs = with pkgs; [ git ];
  };

  # TODO: add conditionally to checks.
  # Run `nix build .#trycmd` to run integration tests
  trycmd-local = naersk'.buildPackage {
    src = ../.;
    mode = "test";
    doCheck = true;
    # No reason to wait for release build
    release = false;
    # buildPhase files differ between dep and main phase
    singleStep = true;
    # set itests files creation date to unix epoch
    buildPhase = ''
      bash devtools/dir-generator.sh tests/test_dir
      bash devtools/generate-timestamp-test-dir.sh tests/timestamp_test_dir
      touch --date=@0 tests/itest/*
      touch --date=@0 tests/ptests/*;
      fd -e stdout -e stderr -H -t file -X sed -i 's/[CWD]\//\/build\/source\//g'
    '';
    cargoTestOptions =
      opts:
      opts
      ++ [
        "--features nix"
        "--features nix-local"
        "--features powertest"
      ];
    inherit buildInputs;
    nativeBuildInputs = with pkgs; [ git ];
  };

  # Run `nix build .#trydump` to dump testing files
  trydump = naersk'.buildPackage {
    src = ../.;
    mode = "test";
    doCheck = true;
    # No reason to wait for release build
    release = false;
    # buildPhase files differ between dep and main phase
    singleStep = true;
    # set itests files creation date to unix epoch
    buildPhase = ''
      bash devtools/dir-generator.sh tests/test_dir
      bash devtools/generate-timestamp-test-dir.sh tests/timestamp_test_dir
      touch --date=@0 tests/itest/*;
      rm tests/cmd/*.stdout || echo;
      rm tests/cmd/*.stderr || echo;

      touch --date=@0 tests/ptests/*;
      rm tests/ptests/*.stdout || echo;
      rm tests/ptests/*.stderr || echo;
    '';
    cargoTestOptions =
      opts:
      opts
      ++ [
        "--features nix"
        "--features nix-local"
        "--features powertest"
        #"-F trycmd/debug"
      ];
    TRYCMD = "dump";
    postInstall = ''
      fd -e stdout -e stderr -H -t file -X sed -i 's/\/build\/source\//[CWD]\//g'

      cp dump $out -r
    '';
    inherit buildInputs;
    nativeBuildInputs = with pkgs; [
      fd
      gnused
      git
    ];
  };
}