feat(powertest): add powertest

Signed-off-by: Christina Sørensen <christina@cafkafk.com>
This commit is contained in:
Christina Sørensen 2023-11-12 09:26:05 +01:00
parent a99638a3dc
commit d6d02d14e8
6 changed files with 186 additions and 4 deletions

View file

@ -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]

View file

@ -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/

View file

@ -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": [

View file

@ -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
powertest.yaml Normal file
View file

@ -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

View file

@ -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");
}