From 4cd9731c156eefed3e4e9015584bfc2db87b9ad3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christina=20S=C3=B8rensen?= Date: Thu, 5 Oct 2023 14:00:18 +0200 Subject: [PATCH] test(local): move classify tests to local MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Here, we introduce the `nix-local` feature, for features meant only to exist locally in the nix sandbox. This is an attempt to avoid the CI runner's unit testing, as that fails to set the grid width correctly. Signed-off-by: Christina Sørensen --- Cargo.toml | 2 ++ Justfile | 2 +- flake.nix | 18 +++++++++++++++++- tests/cli_tests.rs | 6 ++++++ .../cmd/classify-hyperlink-width-50_all.stdout | 5 ----- ...assify-hyperlink-width-50_nix_local.stderr} | 0 ...lassify-hyperlink-width-50_nix_local.stdout | 5 +++++ ...classify-hyperlink-width-50_nix_local.toml} | 0 8 files changed, 31 insertions(+), 7 deletions(-) delete mode 100644 tests/cmd/classify-hyperlink-width-50_all.stdout rename tests/cmd/{classify-hyperlink-width-50_all.stderr => classify-hyperlink-width-50_nix_local.stderr} (100%) create mode 100644 tests/cmd/classify-hyperlink-width-50_nix_local.stdout rename tests/cmd/{classify-hyperlink-width-50_all.toml => classify-hyperlink-width-50_nix_local.toml} (100%) diff --git a/Cargo.toml b/Cargo.toml index 8036dd32..47c19e4e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -118,6 +118,8 @@ vendored-openssl = ["git2/vendored-openssl"] vendored-libgit2 = ["git2/vendored-libgit2"] # Should only be used inside of flake.nix nix = [] +# Should only be used inside of flake.nix locally (not on CI) +nix-local = [] # make dev builds faster by excluding debug symbols diff --git a/Justfile b/Justfile index 956b656e..0d94bc0f 100644 --- a/Justfile +++ b/Justfile @@ -272,7 +272,7 @@ gen_test_dir: # # Required nix, likely won't work on windows. @itest: - nix build -L ./#trycmd + nix build -L ./#trycmd-local # Runs integration tests in nix sandbox, and dumps outputs. # diff --git a/flake.nix b/flake.nix index f383d327..8de8d1e0 100644 --- a/flake.nix +++ b/flake.nix @@ -124,6 +124,22 @@ inherit buildInputs; }; + # 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 = ''touch --date=@0 tests/itest/*''; + cargoTestOptions = opts: opts ++ ["--features nix" "--features nix-local"]; + inherit buildInputs; + }; + # Run `nix build .#trydump` to dump testing files trydump = naersk'.buildPackage { src = ./.; @@ -135,7 +151,7 @@ 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"]; + cargoTestOptions = opts: opts ++ ["--features nix" "--features nix-local"]; TRYCMD = "dump"; postInstall = '' cp dump $out -r diff --git a/tests/cli_tests.rs b/tests/cli_tests.rs index d6c6e436..cf1027ad 100644 --- a/tests/cli_tests.rs +++ b/tests/cli_tests.rs @@ -20,3 +20,9 @@ fn cli_windows_tests() { fn cli_nix_tests() { trycmd::TestCases::new().case("tests/cmd/*_nix.toml"); } + +#[test] +#[cfg(feature = "nix-local")] +fn cli_nix_local_tests() { + trycmd::TestCases::new().case("tests/cmd/*_nix_local.toml"); +} diff --git a/tests/cmd/classify-hyperlink-width-50_all.stdout b/tests/cmd/classify-hyperlink-width-50_all.stdout deleted file mode 100644 index 59a37fb8..00000000 --- a/tests/cmd/classify-hyperlink-width-50_all.stdout +++ /dev/null @@ -1,5 +0,0 @@ -]8;;file:///home/ces/org/src/git/eza/tests/itest/a/a]8;;/ ]8;;file:///home/ces/org/src/git/eza/tests/itest/exa/exa]8;;// ]8;;file:///home/ces/org/src/git/eza/tests/itest/image.jpg.img.c.rs.log.png/image.jpg.img.c.rs.log.png]8;;/ ]8;;file:///home/ces/org/src/git/eza/tests/itest/m/m]8;;/ ]8;;file:///home/ces/org/src/git/eza/tests/itest/vagrant/vagrant]8;;// -]8;;file:///home/ces/org/src/git/eza/tests/itest/b/b]8;;/ ]8;;file:///home/ces/org/src/git/eza/tests/itest/f/f]8;;/ ]8;;file:///home/ces/org/src/git/eza/tests/itest/index.svg/index.svg]8;;/ ]8;;file:///home/ces/org/src/git/eza/tests/itest/n/n]8;;/ -]8;;file:///home/ces/org/src/git/eza/tests/itest/c/c]8;;/ ]8;;file:///home/ces/org/src/git/eza/tests/itest/g/g]8;;/ ]8;;file:///home/ces/org/src/git/eza/tests/itest/j/j]8;;/ ]8;;file:///home/ces/org/src/git/eza/tests/itest/o/o]8;;/ -]8;;file:///home/ces/org/src/git/eza/tests/itest/d/d]8;;/ ]8;;file:///home/ces/org/src/git/eza/tests/itest/h/h]8;;/ ]8;;file:///home/ces/org/src/git/eza/tests/itest/k/k]8;;/ ]8;;file:///home/ces/org/src/git/eza/tests/itest/p/p]8;;/ -]8;;file:///home/ces/org/src/git/eza/tests/itest/e/e]8;;/ ]8;;file:///home/ces/org/src/git/eza/tests/itest/i/i]8;;/ ]8;;file:///home/ces/org/src/git/eza/tests/itest/l/l]8;;/ ]8;;file:///home/ces/org/src/git/eza/tests/itest/q/q]8;;/ diff --git a/tests/cmd/classify-hyperlink-width-50_all.stderr b/tests/cmd/classify-hyperlink-width-50_nix_local.stderr similarity index 100% rename from tests/cmd/classify-hyperlink-width-50_all.stderr rename to tests/cmd/classify-hyperlink-width-50_nix_local.stderr diff --git a/tests/cmd/classify-hyperlink-width-50_nix_local.stdout b/tests/cmd/classify-hyperlink-width-50_nix_local.stdout new file mode 100644 index 00000000..1a79ff3f --- /dev/null +++ b/tests/cmd/classify-hyperlink-width-50_nix_local.stdout @@ -0,0 +1,5 @@ +]8;;file:///build/source/tests/itest/a/a]8;;/ ]8;;file:///build/source/tests/itest/exa/exa]8;;// ]8;;file:///build/source/tests/itest/image.jpg.img.c.rs.log.png/image.jpg.img.c.rs.log.png]8;;/ ]8;;file:///build/source/tests/itest/m/m]8;;/ ]8;;file:///build/source/tests/itest/vagrant/vagrant]8;;// +]8;;file:///build/source/tests/itest/b/b]8;;/ ]8;;file:///build/source/tests/itest/f/f]8;;/ ]8;;file:///build/source/tests/itest/index.svg/index.svg]8;;/ ]8;;file:///build/source/tests/itest/n/n]8;;/ +]8;;file:///build/source/tests/itest/c/c]8;;/ ]8;;file:///build/source/tests/itest/g/g]8;;/ ]8;;file:///build/source/tests/itest/j/j]8;;/ ]8;;file:///build/source/tests/itest/o/o]8;;/ +]8;;file:///build/source/tests/itest/d/d]8;;/ ]8;;file:///build/source/tests/itest/h/h]8;;/ ]8;;file:///build/source/tests/itest/k/k]8;;/ ]8;;file:///build/source/tests/itest/p/p]8;;/ +]8;;file:///build/source/tests/itest/e/e]8;;/ ]8;;file:///build/source/tests/itest/i/i]8;;/ ]8;;file:///build/source/tests/itest/l/l]8;;/ ]8;;file:///build/source/tests/itest/q/q]8;;/ diff --git a/tests/cmd/classify-hyperlink-width-50_all.toml b/tests/cmd/classify-hyperlink-width-50_nix_local.toml similarity index 100% rename from tests/cmd/classify-hyperlink-width-50_all.toml rename to tests/cmd/classify-hyperlink-width-50_nix_local.toml