Skip to content

Commit

Permalink
tests: Install all efmls-configs tools
Browse files Browse the repository at this point in the history
This requires to pass the efmls-configs file to the derivation helpers,
if we try to import it from the test file directly it fails.

We then look into the types to find the available languages &
corresponding tools, to enable them all.

We then filter out the broken tools or the unpackaged tools, in order to
detect more easily the introduction of future tools.
  • Loading branch information
traxys committed Nov 17, 2023
1 parent a304b68 commit d69a0f1
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 2 deletions.
8 changes: 7 additions & 1 deletion tests/fetch-tests.nix
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,13 @@
then args
else {
# cases is a function
cases = cases {inherit pkgs helpers;};
cases = cases {
inherit pkgs helpers;
efmls-options = import ../plugins/lsp/language-servers/efmls-configs.nix {
inherit pkgs lib helpers;
config = {};
};
};
inherit namespace;
})
testsList;
Expand Down
61 changes: 60 additions & 1 deletion tests/test-sources/plugins/lsp/efmls-configs.nix
Original file line number Diff line number Diff line change
@@ -1,8 +1,67 @@
{
{efmls-options, ...}: {
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;

brokenTools = [
#Broken as of 16 of November 2023
"phpstan"
];

unpackaged = [
"blade_formatter"
"cspell"
"dartanalyzer"
"debride"
"fecs"
"fixjson"
"forge_fmt"
"gersemi"
"js_standard"
"pint"
"prettier_eslint"
"prettier_standard"
"redpen"
"reek"
"rome"
"slim_lint"
"solhint"
"sorbet"
"xo"
];

# 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.rawType
# 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 {
enable = true;

# Replace the { <lang> = { linter = tools; formatter = tools; } };
# With { <lang> = {
# linter = [<all valid linters for lang>];
# formatter = [<all valid formatters for lang>];
# };}
setup = builtins.mapAttrs (_: builtins.mapAttrs (_: toolsFromOptions)) toolOptions;
};
};

example = {
extraConfigLuaPre = ''
local efm_fs = require('efmls-configs.fs')
Expand Down

0 comments on commit d69a0f1

Please sign in to comment.