summary refs log tree commit diff
diff options
context:
space:
mode:
authorPatrick Hilhorst <git@hilhorst.be>2022-01-23 16:42:27 +0100
committerPatrick Hilhorst <git@hilhorst.be>2022-01-23 16:42:27 +0100
commit8b86f9816dd46a8b29088ddd91b0a590829f282a (patch)
tree86543f39785d97efb090715c827e4e18b71fc644
parent6d8215281b2f87a5af9ed7425a26ac575da0438f (diff)
downloadnixpkgs-8b86f9816dd46a8b29088ddd91b0a590829f282a.tar
nixpkgs-8b86f9816dd46a8b29088ddd91b0a590829f282a.tar.gz
nixpkgs-8b86f9816dd46a8b29088ddd91b0a590829f282a.tar.bz2
nixpkgs-8b86f9816dd46a8b29088ddd91b0a590829f282a.tar.lz
nixpkgs-8b86f9816dd46a8b29088ddd91b0a590829f282a.tar.xz
nixpkgs-8b86f9816dd46a8b29088ddd91b0a590829f282a.tar.zst
nixpkgs-8b86f9816dd46a8b29088ddd91b0a590829f282a.zip
handbrake: convert nixos test to runCommand
-rw-r--r--nixos/tests/all-tests.nix1
-rw-r--r--nixos/tests/handbrake.nix33
-rw-r--r--pkgs/applications/video/handbrake/default.nix28
3 files changed, 24 insertions, 38 deletions
diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix
index b2f223e7ccd..b22dbc32959 100644
--- a/nixos/tests/all-tests.nix
+++ b/nixos/tests/all-tests.nix
@@ -174,7 +174,6 @@ in
   hadoop.all = handleTestOn [ "x86_64-linux" ] ./hadoop/hadoop.nix {};
   hadoop.hdfs = handleTestOn [ "x86_64-linux" ] ./hadoop/hdfs.nix {};
   hadoop.yarn = handleTestOn [ "x86_64-linux" ] ./hadoop/yarn.nix {};
-  handbrake = handleTestOn ["x86_64-linux"] ./handbrake.nix {};
   haproxy = handleTest ./haproxy.nix {};
   hardened = handleTest ./hardened.nix {};
   hedgedoc = handleTest ./hedgedoc.nix {};
diff --git a/nixos/tests/handbrake.nix b/nixos/tests/handbrake.nix
deleted file mode 100644
index d2d41b372be..00000000000
--- a/nixos/tests/handbrake.nix
+++ /dev/null
@@ -1,33 +0,0 @@
-import ./make-test-python.nix ({ pkgs, ... }:
-
-let
-  # Download Big Buck Bunny example, licensed under CC Attribution 3.0.
-  testMkv = pkgs.fetchurl {
-    url = "https://github.com/Matroska-Org/matroska-test-files/blob/cf0792be144ac470c4b8052cfe19bb691993e3a2/test_files/test1.mkv?raw=true";
-    sha256 = "1hfxbbgxwfkzv85pvpvx55a72qsd0hxjbm9hkl5r3590zw4s75h9";
-    name = "test1.mkv";
-  };
-
-in
-{
-  name = "handbrake";
-
-  meta = {
-    maintainers = with pkgs.lib.maintainers; [ ];
-  };
-
-  machine = { pkgs, ... }: {
-    environment.systemPackages = with pkgs; [ handbrake ];
-  };
-
-  testScript = ''
-    # Test MP4 and MKV transcoding. Since this is a short clip, transcoding typically
-    # only takes a few seconds.
-    start_all()
-
-    machine.succeed("HandBrakeCLI -i ${testMkv} -o test.mp4 -e x264 -q 20 -B 160")
-    machine.succeed("test -e test.mp4")
-    machine.succeed("HandBrakeCLI -i ${testMkv} -o test.mkv -e x264 -q 20 -B 160")
-    machine.succeed("test -e test.mkv")
-  '';
-})
diff --git a/pkgs/applications/video/handbrake/default.nix b/pkgs/applications/video/handbrake/default.nix
index e7ac4881b56..841604399ed 100644
--- a/pkgs/applications/video/handbrake/default.nix
+++ b/pkgs/applications/video/handbrake/default.nix
@@ -10,7 +10,10 @@
 { stdenv
 , lib
 , fetchFromGitHub
-, nixosTests
+  # For tests
+, testVersion
+, runCommand
+, fetchurl
   # Main build tools
 , pkg-config
 , autoconf
@@ -103,7 +106,7 @@ let
   inherit (lib) optional optionals optionalString versions;
 
 in
-stdenv.mkDerivation rec {
+let self = stdenv.mkDerivation rec {
   pname = "handbrake";
   inherit version src;
 
@@ -211,7 +214,23 @@ stdenv.mkDerivation rec {
   makeFlags = [ "--directory=build" ];
 
   passthru.tests = {
-    basic-conversion = nixosTests.handbrake;
+    basic-conversion =
+      let
+        # Big Buck Bunny example, licensed under CC Attribution 3.0.
+        testMkv = fetchurl {
+          url = "https://github.com/Matroska-Org/matroska-test-files/blob/cf0792be144ac470c4b8052cfe19bb691993e3a2/test_files/test1.mkv?raw=true";
+          sha256 = "1hfxbbgxwfkzv85pvpvx55a72qsd0hxjbm9hkl5r3590zw4s75h9";
+        };
+      in
+      runCommand "${pname}-${version}-basic-conversion" { nativeBuildInputs = [ self ]; } ''
+        mkdir -p $out
+        cd $out
+        HandBrakeCLI -i ${testMkv} -o test.mp4 -e x264 -q 20 -B 160
+        test -e test.mp4
+        HandBrakeCLI -i ${testMkv} -o test.mkv -e x264 -q 20 -B 160
+        test -e test.mkv
+      '';
+    version = testVersion { package = self; command = "HandBrakeCLI --version"; };
   };
 
   meta = with lib; {
@@ -230,4 +249,5 @@ stdenv.mkDerivation rec {
     platforms = with platforms; unix;
     broken = stdenv.isDarwin && lib.versionOlder stdenv.hostPlatform.darwinMinVersion "10.13";
   };
-}
+};
+in self