diff options
author | aszlig <aszlig@nix.build> | 2020-10-17 22:08:18 +0200 |
---|---|---|
committer | aszlig <aszlig@nix.build> | 2020-10-17 23:32:03 +0200 |
commit | 5cfdf16dd62dcfa2eb32b4e9ae390cb99d683907 (patch) | |
tree | 5d7c33cfbb65c81434c2eb0db390bee8f63223b0 /tests/github-flakes.nix | |
parent | 2a37c356501d874c7eb4a61468863c57939b0c95 (diff) |
Convert VM tests to Python
Perl-based tests are deprecated since NixOS 20.03 and subsequently got
removed in NixOS 20.09, which effectively means that tests are going to
fail as soon as we build it with NixOS 20.09 or anything newer.
I've put "# fmt: off" at the start of every testScript, because
formatting with Black really messes up indentation and I don't think it
really adds anything in value or readability for inlined Python scripts.
Signed-off-by: aszlig <aszlig@nix.build>
Diffstat (limited to 'tests/github-flakes.nix')
-rw-r--r-- | tests/github-flakes.nix | 45 |
1 files changed, 23 insertions, 22 deletions
diff --git a/tests/github-flakes.nix b/tests/github-flakes.nix index a47610d9a..2de3e2bc0 100644 --- a/tests/github-flakes.nix +++ b/tests/github-flakes.nix @@ -1,6 +1,6 @@ { nixpkgs, system, overlay }: -with import (nixpkgs + "/nixos/lib/testing.nix") { +with import (nixpkgs + "/nixos/lib/testing-python.nix") { inherit system; extraConfigurations = [ { nixpkgs.overlays = [ overlay ]; } ]; }; @@ -113,36 +113,37 @@ makeTest ( }; }; - testScript = { nodes }: - '' - use POSIX qw(strftime); - - startAll; + testScript = { nodes }: '' + # fmt: off + import json + import time - $github->waitForUnit("httpd.service"); + start_all() - $client->succeed("curl -v https://github.com/ >&2"); + github.wait_for_unit("httpd.service") - $client->succeed("nix registry list | grep nixpkgs"); + client.succeed("curl -v https://github.com/ >&2") + client.succeed("nix registry list | grep nixpkgs") - $client->succeed("nix flake info nixpkgs --json | jq -r .revision") eq "${nixpkgs.rev}\n" - or die "revision mismatch"; + rev = client.succeed("nix flake info nixpkgs --json | jq -r .revision") + assert rev.strip() == "${nixpkgs.rev}", "revision mismatch" - $client->succeed("nix registry pin nixpkgs"); + client.succeed("nix registry pin nixpkgs") - $client->succeed("nix flake info nixpkgs --tarball-ttl 0 >&2"); + client.succeed("nix flake info nixpkgs --tarball-ttl 0 >&2") - # Shut down the web server. The flake should be cached on the client. - $github->succeed("systemctl stop httpd.service"); + # Shut down the web server. The flake should be cached on the client. + github.succeed("systemctl stop httpd.service") - my $date = $client->succeed("nix flake info nixpkgs --json | jq -M .lastModified"); - strftime("%Y%m%d%H%M%S", gmtime($date)) eq "${nixpkgs.lastModifiedDate}" or die "time mismatch"; + info = json.loads(client.succeed("nix flake info nixpkgs --json")) + date = time.strftime("%Y%m%d%H%M%S", time.gmtime(info['lastModified'])) + assert date == "${nixpkgs.lastModifiedDate}", "time mismatch" - $client->succeed("nix build nixpkgs#hello"); + client.succeed("nix build nixpkgs#hello") - # The build shouldn't fail even with --tarball-ttl 0 (the server - # being down should not be a fatal error). - $client->succeed("nix build nixpkgs#fuse --tarball-ttl 0"); - ''; + # The build shouldn't fail even with --tarball-ttl 0 (the server + # being down should not be a fatal error). + client.succeed("nix build nixpkgs#fuse --tarball-ttl 0") + ''; }) |