Преглед на файлове

feat(powertest): add powertest

Signed-off-by: Christina Sørensen <christina@cafkafk.com>
Christina Sørensen преди 2 години
родител
ревизия
d6d02d14e8
променени са 6 файла, в които са добавени 186 реда и са изтрити 4 реда
  1. 3 0
      Cargo.toml
  2. 3 0
      Justfile
  3. 61 1
      flake.lock
  4. 24 3
      flake.nix
  5. 89 0
      powertest.yaml
  6. 6 0
      tests/cli_tests.rs

+ 3 - 0
Cargo.toml

@@ -121,6 +121,9 @@ vendored-libgit2 = ["git2/vendored-libgit2"]
 nix = []
 # Should only be used inside of flake.nix locally (not on CI)
 nix-local = []
+# Should only be used inside of flake.nix
+# Shouldn't ever be used in CI (slow!)
+powertest = []
 
 # use LTO for smaller binaries (that take longer to build)
 [profile.release]

+ 3 - 0
Justfile

@@ -355,5 +355,8 @@ gen_test_dir:
 @idump:
     rm ./tests/cmd/*nix.stderr -f || echo
     rm ./tests/cmd/*nix.stdout -f || echo
+    rm ./tests/ptests/ptest_tests*.stderr -f || echo  
+    rm ./tests/ptests/ptest_tests*.stdout -f || echo
     nix build -L ./#trydump
     cp ./result/dump/*nix.* ./tests/cmd/
+    cp ./result/dump/ptest_tests*.* ./tests/ptests/

+ 61 - 1
flake.lock

@@ -50,6 +50,24 @@
       "inputs": {
         "systems": "systems_2"
       },
+      "locked": {
+        "lastModified": 1694529238,
+        "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=",
+        "owner": "numtide",
+        "repo": "flake-utils",
+        "rev": "ff7b65b44d01cf9ba6a71320833626af21126384",
+        "type": "github"
+      },
+      "original": {
+        "owner": "numtide",
+        "repo": "flake-utils",
+        "type": "github"
+      }
+    },
+    "flake-utils_3": {
+      "inputs": {
+        "systems": "systems_3"
+      },
       "locked": {
         "lastModified": 1681202837,
         "narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=",
@@ -128,6 +146,32 @@
         "type": "github"
       }
     },
+    "powertest": {
+      "inputs": {
+        "flake-utils": "flake-utils_2",
+        "naersk": [
+          "naersk"
+        ],
+        "nixpkgs": [
+          "nixpkgs"
+        ],
+        "rust-overlay": [
+          "rust-overlay"
+        ],
+        "treefmt-nix": [
+          "treefmt-nix"
+        ]
+      },
+      "locked": {
+        "narHash": "sha256-ZiOjGJPz2KaeWpPYD71rLGD+Y8OOeUFL9q6COkI6fCU=",
+        "type": "tarball",
+        "url": "http://rime.cx/v1/github/eza-community/powertest/b/main.tar.gz"
+      },
+      "original": {
+        "type": "tarball",
+        "url": "http://rime.cx/v1/github/eza-community/powertest/b/main.tar.gz"
+      }
+    },
     "pre-commit-hooks": {
       "inputs": {
         "flake-compat": "flake-compat",
@@ -156,6 +200,7 @@
         "flake-utils": "flake-utils",
         "naersk": "naersk",
         "nixpkgs": "nixpkgs",
+        "powertest": "powertest",
         "pre-commit-hooks": "pre-commit-hooks",
         "rust-overlay": "rust-overlay",
         "treefmt-nix": "treefmt-nix"
@@ -163,7 +208,7 @@
     },
     "rust-overlay": {
       "inputs": {
-        "flake-utils": "flake-utils_2",
+        "flake-utils": "flake-utils_3",
         "nixpkgs": [
           "nixpkgs"
         ]
@@ -208,6 +253,21 @@
         "type": "github"
       }
     },
+    "systems_3": {
+      "locked": {
+        "lastModified": 1681028828,
+        "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
+        "owner": "nix-systems",
+        "repo": "default",
+        "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
+        "type": "github"
+      },
+      "original": {
+        "owner": "nix-systems",
+        "repo": "default",
+        "type": "github"
+      }
+    },
     "treefmt-nix": {
       "inputs": {
         "nixpkgs": [

+ 24 - 3
flake.nix

@@ -23,6 +23,16 @@
       inputs.nixpkgs.follows = "nixpkgs";
     };
 
+    powertest = {
+      url = "http://rime.cx/v1/github/eza-community/powertest/b/main.tar.gz";
+      inputs = {
+        nixpkgs.follows = "nixpkgs";
+        naersk.follows = "naersk";
+        treefmt-nix.follows = "treefmt-nix";
+        rust-overlay.follows = "rust-overlay";
+      };
+    };
+
     pre-commit-hooks = {
       url = "http://rime.cx/v1/github/semnix/pre-commit-hooks.nix.tar.gz";
       inputs.nixpkgs.follows = "nixpkgs";
@@ -42,6 +52,7 @@
     nixpkgs,
     treefmt-nix,
     rust-overlay,
+    powertest,
     pre-commit-hooks,
     ...
   }:
@@ -158,7 +169,7 @@
             singleStep = true;
             # set itests files creation date to unix epoch
             buildPhase = ''touch --date=@0 tests/itest/*'';
-            cargoTestOptions = opts: opts ++ ["--features nix" "--features nix-local"];
+            cargoTestOptions = opts: opts ++ ["--features nix" "--features nix-local" "--features powertest"];
             inherit buildInputs;
           };
 
@@ -172,8 +183,16 @@
             # buildPhase files differ between dep and main phase
             singleStep = true;
             # set itests files creation date to unix epoch
-            buildPhase = ''touch --date=@0 tests/itest/*; rm tests/cmd/*.stdout || echo; rm tests/cmd/*.stderr || echo;'';
-            cargoTestOptions = opts: opts ++ ["--features nix" "--features nix-local"];
+            buildPhase = ''
+              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"];
             TRYCMD = "dump";
             postInstall = ''
               cp dump $out -r
@@ -196,6 +215,8 @@
             # For generating demo
             vhs
 
+            powertest.packages.${pkgs.system}.default
+
             cargo-hack
             cargo-udeps
             cargo-outdated

+ 89 - 0
powertest.yaml

@@ -0,0 +1,89 @@
+dump_dir: tests/ptests
+depth: 1
+binary: eza
+gen_binary: target/debug/eza
+args: tests/itest
+commands:
+  ? - null
+    - --color
+  : values:
+      - auto
+      - always
+      - never
+  ? - null
+    - --colour
+  : values:
+      - auto
+      - always
+      - never
+  ? - null
+    - --icons
+  ? - -L
+    - --level
+  : prefix:
+      --tree
+    values:
+      - 1
+      - 2
+      - 3
+      - 4
+      - 5
+  ? - -w
+    - --width
+  : values:
+      - 1
+      - 2
+      - 3
+      - 4
+      - 5
+  ? - -t
+    - --time
+  : prefix: -l
+    values:
+      - modified
+      - accessed
+      - changed
+      - created
+  # TODO: add more globs
+  ? - -I
+    - --ignore-glob
+  : prefix: -l
+    values:
+      - "*.toml"
+  ? - null
+    - --time-style
+  : long: time-style
+    values:
+      - default
+      - iso
+      - long-iso
+      - full-iso
+      - relative
+  ? - -s
+    - --sort
+  : short: -s
+    long: time-style
+    prefix: -l
+    values:
+      - accessed
+      - age
+      - changed
+      - created
+      - date
+      - Ext
+      - ext
+      - Extension
+      - extension
+      - Filename
+      - filename
+      - inode
+      - modified
+      - Name
+      - name
+      - newest
+      - none
+      - oldest
+      - size
+      - time
+      - type
+

+ 6 - 0
tests/cli_tests.rs

@@ -26,3 +26,9 @@ fn cli_nix_tests() {
 fn cli_nix_local_tests() {
     trycmd::TestCases::new().case("tests/cmd/*_nix_local.toml");
 }
+
+#[test]
+#[cfg(feature = "powertest")]
+fn cli_powertest_tests() {
+    trycmd::TestCases::new().case("tests/ptests/*.toml");
+}