diff --git a/lib/default.nix b/lib/default.nix index dfa69f1..92d2399 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -1,4 +1,9 @@ -{pkgs, ...}: { +{ + pkgs, + lib ? pkgs.lib, + self ? "", + ... +}: { mkTest = { type ? "unit", name, @@ -7,13 +12,15 @@ actual ? null, actualDrv ? null, pos ? null, - }: { + }: let + fileRelative = lib.removePrefix ((toString self) + "/") pos.file; + in { inherit type name description expected actual; actualDrv = actualDrv.drvPath or ""; pos = if pos == null then "" - else "${pos.file}:${toString pos.line}:${toString pos.column}"; + else "${fileRelative}:${toString pos.line}:${toString pos.column}"; }; mkSuite = name: tests: { inherit name tests; diff --git a/lib/flakeModule.nix b/lib/flakeModule.nix index 12d900f..0d09608 100644 --- a/lib/flakeModule.nix +++ b/lib/flakeModule.nix @@ -1,6 +1,7 @@ { flake-parts-lib, lib, + self, ... }: let inherit (lib) mkOption types; @@ -11,7 +12,7 @@ in { pkgs, ... }: let - nixtests-lib = import ./. {inherit pkgs;}; + nixtests-lib = import ./. {inherit pkgs self;}; in { options.testSuites = mkOption { type = types.attrsOf (types.listOf types.attrs);