Compare commits

..

No commits in common. "22b43c9fe83be73c3f0648bbb54bc3c1cf7f96df" and "c2a1208534fbdd8ab28ff3e45262b527f81a1755" have entirely different histories.

5 changed files with 13 additions and 37 deletions

View file

@ -2,7 +2,7 @@
[![built with nix](https://img.shields.io/static/v1?logo=nixos&logoColor=white&label=&message=Built%20with%20Nix&color=41439a)](https://builtwithnix.org)
[![pipeline status](https://gitlab.com/TECHNOFAB/nixtest/badges/main/pipeline.svg)](https://gitlab.com/TECHNOFAB/nixtest/-/commits/main)
![License: MIT](https://img.shields.io/gitlab/license/technofab/nixtest)
![License: MIT](https://img.shields.io/gitlab/license/technofab/nix-gitlab-ci)
[![Latest Release](https://gitlab.com/TECHNOFAB/nixtest/-/badges/release.svg)](https://gitlab.com/TECHNOFAB/nixtest/-/releases)
[![Support me](https://img.shields.io/badge/Support-me-green)](https://tec.tf/#support)
[![Docs](https://img.shields.io/badge/Read-Docs-green)](https://nixtest.projects.tf)

View file

@ -36,12 +36,9 @@
};
devenv.shells.default = {
containers = pkgs.lib.mkForce {};
packages = with pkgs; [gore go-junit-report];
packages = with pkgs; [gopls gore go-junit-report];
languages.go = {
enable = true;
enableHardeningWorkaround = true;
};
languages.go.enable = true;
pre-commit.hooks = {
treefmt = {

View file

@ -39,11 +39,7 @@ in rec {
}: let
files = builtins.readDir dir;
matchingFiles = builtins.filter (name: builtins.match pattern name != null) (builtins.attrNames files);
imports = map (file:
if builtins.isString dir
then (builtins.unsafeDiscardStringContext dir) + "/${file}"
else /${dir}/${file})
matchingFiles;
imports = map (file: /${dir}/${file}) matchingFiles;
in {
inherit imports;
# automatically set the base so test filepaths are easier to read

View file

@ -3,17 +3,7 @@
lib,
...
}: let
inherit
(lib)
mkOptionType
mkOption
types
filterAttrs
isType
removePrefix
assertMsg
generators
;
inherit (lib) mkOptionType mkOption types;
nixtest-lib = import ./default.nix {inherit pkgs lib;};
@ -26,14 +16,14 @@
unset = {
_type = "unset";
};
isUnset = isType "unset";
isUnset = lib.isType "unset";
filterUnset = value:
if builtins.isAttrs value && !builtins.hasAttr "_type" value
then let
filteredAttrs = builtins.mapAttrs (n: v: filterUnset v) value;
in
filterAttrs (name: value: (!isUnset value)) filteredAttrs
lib.filterAttrs (name: value: (!isUnset value)) filteredAttrs
else if builtins.isList value
then builtins.filter (elem: !isUnset elem) (map filterUnset value)
else value;
@ -52,18 +42,18 @@
if isUnset val
then val
else let
fileRelative = removePrefix testsBase val.file;
fileRelative = lib.removePrefix testsBase val.file;
in "${fileRelative}:${toString val.line}";
};
type = mkOption {
type = types.enum ["unit" "snapshot" "script"];
default = "unit";
apply = value:
assert assertMsg (value != "script" || !isUnset config.script)
assert lib.assertMsg (value != "script" || !isUnset config.script)
"test '${config.name}' as type 'script' requires 'script' to be set";
assert assertMsg (value != "unit" || !isUnset config.expected)
assert lib.assertMsg (value != "unit" || !isUnset config.expected)
"test '${config.name}' as type 'unit' requires 'expected' to be set";
assert assertMsg (
assert lib.assertMsg (
let
actualIsUnset = isUnset config.actual;
actualDrvIsUnset = isUnset config.actualDrv;
@ -91,7 +81,7 @@
apply = val:
if isUnset val || config.format == "json"
then val
else generators.toPretty {} val;
else lib.generators.toPretty {} val;
};
actual = mkOption {
type = types.anything;
@ -99,7 +89,7 @@
apply = val:
if isUnset val || config.format == "json"
then val
else generators.toPretty {} val;
else lib.generators.toPretty {} val;
};
actualDrv = mkOption {
type = types.either types.package unsetType;

View file

@ -13,10 +13,6 @@
actual = ntlib.helpers.toPrettyFile (ntlib.autodiscover {
dir = ./fixtures;
});
# tests if strings with store path context work
actualDirString = ntlib.helpers.toPrettyFile (ntlib.autodiscover {
dir = "${./fixtures}";
});
in
# sh
''
@ -24,9 +20,6 @@
${ntlib.helpers.scriptHelpers}
assert_file_contains ${actual} "sample_test.nix" "should find sample_test.nix"
assert_file_contains ${actual} "base = \"/nix/store/.*-source/tests/fixtures/\"" "should set base to fixtures dir"
assert_file_contains ${actualDirString} "sample_test.nix" "should find sample_test.nix"
assert_file_contains ${actualDirString} "base = \"/nix/store/.*-fixtures/\"" "should set base to fixtures dir"
'';
}
{