From 00d158e8fd9dd97cf2311105ea799ab5ee9baf11 Mon Sep 17 00:00:00 2001 From: Francesco Gazzetta Date: Thu, 6 Oct 2022 14:30:27 +0200 Subject: [PATCH] nixosTests.minetest-with-packages: init --- nixos/tests/all-tests.nix | 1 + nixos/tests/minetest-with-packages.nix | 56 ++++++++++++++++++++++++++ pkgs/games/minetest/default.nix | 5 +++ 3 files changed, 62 insertions(+) create mode 100644 nixos/tests/minetest-with-packages.nix diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 0fc08e841ec07..5d86eb80c4e67 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -367,6 +367,7 @@ in { metabase = handleTest ./metabase.nix {}; minecraft = handleTest ./minecraft.nix {}; minecraft-server = handleTest ./minecraft-server.nix {}; + minetest-with-packages = handleTest ./minetest-with-packages.nix {}; minidlna = handleTest ./minidlna.nix {}; miniflux = handleTest ./miniflux.nix {}; minio = handleTest ./minio.nix {}; diff --git a/nixos/tests/minetest-with-packages.nix b/nixos/tests/minetest-with-packages.nix new file mode 100644 index 0000000000000..f82e89f642576 --- /dev/null +++ b/nixos/tests/minetest-with-packages.nix @@ -0,0 +1,56 @@ +import ./make-test-python.nix ({ pkgs, lib, ... }: { + name = "minetest-with-packages"; + meta = with lib.maintainers; { maintainers = [ fgaz ]; }; + + nodes.machine = { config, pkgs, ... }: { + imports = [ + ./common/x11.nix + ]; + + virtualisation.memorySize = 2047; + + services.xserver.enable = true; + sound.enable = true; + environment.systemPackages = [ + (pkgs.minetestWithPackages (mtps: [ mtps.contentDB.Wuzzy.mineclone2 ])) + ]; + }; + + testScript = { nodes, ... }: + let + world = pkgs.writeText "world.mt" '' + mod_storage_backend = sqlite3 + auth_backend = sqlite3 + player_backend = sqlite3 + backend = sqlite3 + gameid = mineclone2 + world_name = mcl_test + ''; + map_meta = pkgs.writeText "map_meta.txt" '' + mg_name = v7 + seed = 0 + [end_of_params] + ''; + in '' + # Set up a basic mineclone2 world + machine.succeed("mkdir -p ~/.minetest/worlds/mcl_test") + machine.copy_from_host("${world}", "/root/.minetest/worlds/mcl_test/world.mt") + machine.copy_from_host("${map_meta}", "/root/.minetest/worlds/mcl_test/map_meta.txt") + + machine.wait_for_x() + # Add a dummy sound card, or we'll have a sound error in the log + machine.execute("modprobe snd-dummy") + + # Test clean shutdown (on SIGTERM). + # We have to check for "ERROR" strings because minetest exits with code 0 + # on certain errors (such as missing world). + machine.succeed("timeout --preserve-status -k60 120 minetest --go --worldname mcl_test 2>&1 | tee output") + machine.succeed('[ -z "$(grep ERROR output)" ]') + + # Take a screenshot of the game. + machine.execute("minetest --go --worldname mcl_test >&2 &") + machine.wait_for_window(r"Singleplayer") + machine.sleep(10) + machine.screenshot("screen") + ''; +}) diff --git a/pkgs/games/minetest/default.nix b/pkgs/games/minetest/default.nix index 57515685a7609..c1c43a7f8bb08 100644 --- a/pkgs/games/minetest/default.nix +++ b/pkgs/games/minetest/default.nix @@ -37,6 +37,7 @@ , Carbon , Cocoa , withTouchSupport ? false +, nixosTests }: with lib; @@ -115,6 +116,10 @@ let patchShebangs $out ''; + passthru.tests = { + minetest-with-packages = nixosTests.minetest-with-packages; + }; + meta = with lib; { homepage = "http://minetest.net/"; description = "Infinite-world block sandbox game";