Skip to content

Commit

Permalink
tests: remove special case for efmls-configs
Browse files Browse the repository at this point in the history
  • Loading branch information
MattSturgeon committed Aug 22, 2024
1 parent 0641962 commit 087f70c
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 98 deletions.
17 changes: 2 additions & 15 deletions tests/fetch-tests.nix
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,8 @@ let
testsList = lib.lists.flatten (parseDirectories root [ ]);

testsListEvaluated = builtins.map (
{ cases, namespace }@args:
if builtins.isAttrs cases then
args
else
{
# cases is a function
cases = cases {
inherit pkgs helpers;
efmls-options = import ../plugins/lsp/language-servers/efmls-configs.nix {
inherit pkgs lib helpers;
config = { };
};
};
inherit namespace;
}
{ cases, ... }@args:
if builtins.isFunction cases then args // { cases = cases { inherit pkgs lib helpers; }; } else args
) testsList;

# Take a list of test cases (i.e the content of a file) and prepare a test case that can be
Expand Down
176 changes: 93 additions & 83 deletions tests/test-sources/plugins/lsp/efmls-configs.nix
Original file line number Diff line number Diff line change
@@ -1,93 +1,103 @@
{ efmls-options, pkgs, ... }:
{
empty = {
plugins.efmls-configs.enable = true;
};

all = {
plugins.efmls-configs =
let
options = efmls-options.options.plugins.efmls-configs;
# toolOptions is an attrsets of the form:
# { <lang> = { linter = tools; formatter = tools; }; }
# Where tools is the option type representing the valid tools for this language
toolOptions = (builtins.head options.setup.type.getSubModules).options;
all =
{
lib,
options,
pkgs,
...
}:
let
inherit (pkgs.stdenv.hostPlatform) system;
inherit (options.plugins.efmls-configs) setup;

brokenTools =
[
# Broken as of 2024-07-08
# TODO: re-enable this tests when fixed
"cpplint"
]
++ pkgs.lib.optionals (pkgs.stdenv.hostPlatform.system == "aarch64-linux") [
# Broken as of 2024-07-13
# TODO: re-enable this tests when fixed
"textlint"
]
++ pkgs.lib.optionals pkgs.stdenv.isDarwin [
# As of 2024-01-04, texliveMedium is broken on darwin
# TODO: re-enable those tests when fixed
"chktex"
"latexindent"
]
++ pkgs.lib.optionals (pkgs.stdenv.hostPlatform.system == "x86_64-darwin") [
# As of 2024-07-31, dmd is broken on x86_64-darwin
# https://github.com/NixOS/nixpkgs/pull/331373
# TODO: re-enable this test when fixed
"dmd"
# As of 2024-01-04, luaformat is broken on x86_64-darwin
# TODO: re-enable this test when fixed
"lua_format"
];
# toolOptions is an attrsets of the form:
# { <lang> = { linter = tools; formatter = tools; }; }
# Where tools is the option type representing the valid tools for this language
toolOptions = builtins.removeAttrs (setup.type.getSubOptions setup.loc) [
"_freeformOptions"
"_module"
];

brokenTools =
[
# Broken as of 2024-07-08
# TODO: re-enable this tests when fixed
"cpplint"
]
++ lib.optionals (system == "aarch64-linux") [
# Broken as of 2024-07-13
# TODO: re-enable this tests when fixed
"textlint"
]
++ lib.optionals pkgs.stdenv.isDarwin [
# As of 2024-01-04, texliveMedium is broken on darwin
# TODO: re-enable those tests when fixed
"chktex"
"latexindent"
]
++ lib.optionals (system == "x86_64-darwin") [
# As of 2024-07-31, dmd is broken on x86_64-darwin
# https://github.com/NixOS/nixpkgs/pull/331373
# TODO: re-enable this test when fixed
"dmd"
# As of 2024-01-04, luaformat is broken on x86_64-darwin
# TODO: re-enable this test when fixed
"lua_format"
];

unpackaged =
[
"blade_formatter"
"cspell"
"cljstyle"
"dartanalyzer"
"debride"
"deno_fmt"
"fecs"
"fixjson"
"forge_fmt"
"gersemi"
"js_standard"
"pint"
"prettier_eslint"
"prettier_standard"
"redpen"
"reek"
"rome"
"slim_lint"
"solhint"
"sorbet"
"swiftformat"
"swiftlint"
"xo"
]
++ (pkgs.lib.optionals pkgs.stdenv.isDarwin [ "clazy" ])
++ (pkgs.lib.optionals pkgs.stdenv.isAarch64 [
"dmd"
"smlfmt"
]);
unpackaged =
[
"blade_formatter"
"cspell"
"cljstyle"
"dartanalyzer"
"debride"
"deno_fmt"
"fecs"
"fixjson"
"forge_fmt"
"gersemi"
"js_standard"
"pint"
"prettier_eslint"
"prettier_standard"
"redpen"
"reek"
"rome"
"slim_lint"
"solhint"
"sorbet"
"swiftformat"
"swiftlint"
"xo"
]
++ lib.optionals pkgs.stdenv.isDarwin [ "clazy" ]
++ lib.optionals pkgs.stdenv.isAarch64 [
"dmd"
"smlfmt"
];

# Fetch the valid enum members from the tool options
toolsFromOptions =
opt:
let
# tool options are a `either toolType (listOf toolType)`
# Look into `nestedTypes.left` to get a `toolType` option.
toolType = opt.type.nestedTypes.left;
# toolType is a `either (enum possible) helpers.nixvimTypes.rawLua
# Look into `nestedTypes.left` for the enum
possible = toolType.nestedTypes.left;
# possible is an enum, look into functor.payload for the variants
toolList = possible.functor.payload;
in
builtins.filter (t: !builtins.elem t (brokenTools ++ unpackaged)) toolList;
in
{
# Fetch the valid enum members from the tool options
toolsFromOptions =
opt:
let
# tool options are a `either toolType (listOf toolType)`
# Look into `nestedTypes.left` to get a `toolType` option.
toolType = opt.type.nestedTypes.left;
# toolType is a `either (enum possible) helpers.nixvimTypes.rawLua
# Look into `nestedTypes.left` for the enum
possible = toolType.nestedTypes.left;
# possible is an enum, look into functor.payload for the variants
toolList = possible.functor.payload;
in
builtins.filter (t: !builtins.elem t (brokenTools ++ unpackaged)) toolList;
in
{
plugins.efmls-configs = {
enable = true;

# Replace the { <lang> = { linter = tools; formatter = tools; } };
Expand All @@ -97,7 +107,7 @@
# };}
setup = builtins.mapAttrs (_: builtins.mapAttrs (_: toolsFromOptions)) toolOptions;
};
};
};

example = {
extraConfigLuaPre = ''
Expand Down

0 comments on commit 087f70c

Please sign in to comment.