Commit 244229a8 authored by nicoo's avatar nicoo
Browse files

python3Packages.bork: add test using `testers.runCommand`

This will serve as a “real-world” example, running tests requiring network.
parent d0a96c6e
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -19,6 +19,8 @@ lib.recurseIntoAttrs {
  shellcheck = pkgs.callPackage ../shellcheck/tests.nix { };

  runCommand = lib.recurseIntoAttrs {
    bork = pkgs.python3Packages.bork.tests.pytest-network;

    dns-resolution = testers.runCommand {
      name = "runCommand-dns-resolution-test";
      nativeBuildInputs = [ pkgs.ldns ];
+3 −0
Original line number Diff line number Diff line
{
  lib,
  buildPythonPackage,
  callPackage,
  fetchFromGitHub,
  pytestCheckHook,
  pythonOlder,
@@ -61,6 +62,8 @@ buildPythonPackage rec {
    "test_repo"
  ];

  passthru.tests = callPackage ./tests.nix { };

  meta = with lib; {
    description = "Python build and release management tool";
    mainProgram = "bork";
+28 −0
Original line number Diff line number Diff line
{
  testers,

  bork,
  cacert,
  git,
  pytest,
}:
{
  # a.k.a. `tests.testers.runCommand.bork`
  pytest-network = testers.runCommand {
    name = "bork-pytest-network";
    nativeBuildInputs = [
      bork
      cacert
      git
      pytest
    ];
    script = ''
      # Copy the source tree over, and make it writeable
      cp -r ${bork.src} bork/
      find -type d -exec chmod 0755 '{}' '+'

      pytest -v -m network bork/
      touch $out
    '';
  };
}