Skip to content

Commit

Permalink
nixosTests.minetest-with-packages: init
Browse files Browse the repository at this point in the history
  • Loading branch information
fgaz committed Oct 20, 2022
1 parent 1cfbd70 commit 00d158e
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 0 deletions.
1 change: 1 addition & 0 deletions nixos/tests/all-tests.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 {};
Expand Down
56 changes: 56 additions & 0 deletions nixos/tests/minetest-with-packages.nix
Original file line number Diff line number Diff line change
@@ -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")
'';
})
5 changes: 5 additions & 0 deletions pkgs/games/minetest/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
, Carbon
, Cocoa
, withTouchSupport ? false
, nixosTests
}:

with lib;
Expand Down Expand Up @@ -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";
Expand Down

0 comments on commit 00d158e

Please sign in to comment.