Loading pkgs/applications/emulators/craftos-pc/default.nix +6 −0 Original line number Diff line number Diff line { lib , stdenv , fetchFromGitHub , callPackage , patchelf , unzip , poco Loading Loading @@ -59,6 +60,11 @@ stdenv.mkDerivation rec { cp -R ${craftos2-rom}/* $out/share/craftos ''; passthru.tests = { eval-hello-world = callPackage ./test-eval-hello-world { }; eval-periphemu = callPackage ./test-eval-periphemu { }; }; meta = with lib; { description = "An implementation of the CraftOS-PC API written in C++ using SDL"; homepage = "https://www.craftos-pc.cc"; Loading pkgs/applications/emulators/craftos-pc/test-eval-hello-world/default.nix 0 → 100644 +18 −0 Original line number Diff line number Diff line { stdenv , craftos-pc , grep }: stdenv.mkDerivation { name = "craftos-pc-test-eval-hello-world"; meta.timeout = 60; nativeBuildInputs = [ craftos-pc grep ]; buildCommand = '' export HOME=$(pwd) mkdir $HOME/.local $HOME/.config export XDG_CONFIG_DIR=$HOME/.config export XDG_DATA_DIR=$HOME/.local craftos --headless --script ${./init.lua} | grep "Hello Nixpkgs!" > /dev/null touch $out ''; } pkgs/applications/emulators/craftos-pc/test-eval-hello-world/init.lua 0 → 100644 +3 −0 Original line number Diff line number Diff line print("Hello Nixpkgs!") shell.run("shutdown") pkgs/applications/emulators/craftos-pc/test-eval-periphemu/default.nix 0 → 100644 +19 −0 Original line number Diff line number Diff line { stdenv , craftos-pc , grep }: stdenv.mkDerivation { name = "craftos-pc-test-eval-periphemu"; meta.timeout = 60; nativeBuildInputs = [ craftos-pc grep ]; buildCommand = '' export HOME=$(pwd) mkdir $HOME/.local $HOME/.config export XDG_CONFIG_DIR=$HOME/.config export XDG_DATA_DIR=$HOME/.local if craftos --headless --script ${./init.lua} | grep -q "FAIL"; then exit 1 fi touch $out ''; } pkgs/applications/emulators/craftos-pc/test-eval-periphemu/init.lua 0 → 100644 +18 −0 Original line number Diff line number Diff line local function assert(cond1, cond2) if not cond1 == cond2 then print("FAIL") end end local function driveTests() periphemu.create("left", "drive") local p = peripheral.wrap("left") assert(p.isDiskPresent(), false) p.insertDisk(649) assert(p.isDiskPresent(), true) assert(p.getDiskID(), 649) assert(p.getDiskLabel(), nil) end driveTests() shell.run("shutdown") Loading
pkgs/applications/emulators/craftos-pc/default.nix +6 −0 Original line number Diff line number Diff line { lib , stdenv , fetchFromGitHub , callPackage , patchelf , unzip , poco Loading Loading @@ -59,6 +60,11 @@ stdenv.mkDerivation rec { cp -R ${craftos2-rom}/* $out/share/craftos ''; passthru.tests = { eval-hello-world = callPackage ./test-eval-hello-world { }; eval-periphemu = callPackage ./test-eval-periphemu { }; }; meta = with lib; { description = "An implementation of the CraftOS-PC API written in C++ using SDL"; homepage = "https://www.craftos-pc.cc"; Loading
pkgs/applications/emulators/craftos-pc/test-eval-hello-world/default.nix 0 → 100644 +18 −0 Original line number Diff line number Diff line { stdenv , craftos-pc , grep }: stdenv.mkDerivation { name = "craftos-pc-test-eval-hello-world"; meta.timeout = 60; nativeBuildInputs = [ craftos-pc grep ]; buildCommand = '' export HOME=$(pwd) mkdir $HOME/.local $HOME/.config export XDG_CONFIG_DIR=$HOME/.config export XDG_DATA_DIR=$HOME/.local craftos --headless --script ${./init.lua} | grep "Hello Nixpkgs!" > /dev/null touch $out ''; }
pkgs/applications/emulators/craftos-pc/test-eval-hello-world/init.lua 0 → 100644 +3 −0 Original line number Diff line number Diff line print("Hello Nixpkgs!") shell.run("shutdown")
pkgs/applications/emulators/craftos-pc/test-eval-periphemu/default.nix 0 → 100644 +19 −0 Original line number Diff line number Diff line { stdenv , craftos-pc , grep }: stdenv.mkDerivation { name = "craftos-pc-test-eval-periphemu"; meta.timeout = 60; nativeBuildInputs = [ craftos-pc grep ]; buildCommand = '' export HOME=$(pwd) mkdir $HOME/.local $HOME/.config export XDG_CONFIG_DIR=$HOME/.config export XDG_DATA_DIR=$HOME/.local if craftos --headless --script ${./init.lua} | grep -q "FAIL"; then exit 1 fi touch $out ''; }
pkgs/applications/emulators/craftos-pc/test-eval-periphemu/init.lua 0 → 100644 +18 −0 Original line number Diff line number Diff line local function assert(cond1, cond2) if not cond1 == cond2 then print("FAIL") end end local function driveTests() periphemu.create("left", "drive") local p = peripheral.wrap("left") assert(p.isDiskPresent(), false) p.insertDisk(649) assert(p.isDiskPresent(), true) assert(p.getDiskID(), 649) assert(p.getDiskLabel(), nil) end driveTests() shell.run("shutdown")