From aaa7d9b00cf46fe2c228e7c6663494f42dfe2b65 Mon Sep 17 00:00:00 2001 From: Yingchi Long Date: Wed, 17 Apr 2024 13:53:18 +0800 Subject: [PATCH] nixd/attrs-eval: do not eval real nixpkgs --- .../test/attrs-completion-scope.md | 10 ++---- .../test/attrs-completion.md | 36 +++---------------- .../nixd-attrset-eval/test/attrs-info.md | 2 +- .../nixd-attrset-eval/test/option-complete.md | 21 ++++++++++- .../nixd-attrset-eval/test/option-info.md | 32 +++++++++++++---- 5 files changed, 53 insertions(+), 48 deletions(-) diff --git a/nixd/tools/nixd-attrset-eval/test/attrs-completion-scope.md b/nixd/tools/nixd-attrset-eval/test/attrs-completion-scope.md index aa405f394..b78272bc3 100644 --- a/nixd/tools/nixd-attrset-eval/test/attrs-completion-scope.md +++ b/nixd/tools/nixd-attrset-eval/test/attrs-completion-scope.md @@ -6,7 +6,7 @@ "jsonrpc":"2.0", "id":0, "method":"attrset/evalExpr", - "params": "import { }" + "params": "{ a = 1; llvmPackages = { clang = 1; clang-manpages = 1; }; }" } ``` @@ -28,13 +28,7 @@ CHECK-NEXT: "jsonrpc": "2.0", CHECK-NEXT: "result": [ CHECK-NEXT: "clang", -CHECK-NEXT: "clang-manpages", -CHECK-NEXT: "clang-unwrapped", -CHECK-NEXT: "clangNoCompilerRt", -CHECK-NEXT: "clangNoCompilerRtWithLibc", -CHECK-NEXT: "clangNoLibc", -CHECK-NEXT: "clangNoLibcxx", -CHECK-NEXT: "clangUseLLVM" +CHECK-NEXT: "clang-manpages" ``` ```json diff --git a/nixd/tools/nixd-attrset-eval/test/attrs-completion.md b/nixd/tools/nixd-attrset-eval/test/attrs-completion.md index 52f96d9ba..a1a87cf24 100644 --- a/nixd/tools/nixd-attrset-eval/test/attrs-completion.md +++ b/nixd/tools/nixd-attrset-eval/test/attrs-completion.md @@ -6,7 +6,7 @@ "jsonrpc":"2.0", "id":0, "method":"attrset/evalExpr", - "params": "import { }" + "params": "{ py1 = 1; py2 = 2; py3 = 3; }" } ``` @@ -27,37 +27,9 @@ CHECK: "id": 1, CHECK-NEXT: "jsonrpc": "2.0", CHECK-NEXT: "result": [ -CHECK-NEXT: "py-spy", -CHECK-NEXT: "py3c", -CHECK-NEXT: "py65", -CHECK-NEXT: "pyCA", -CHECK-NEXT: "pycflow2dot", -CHECK-NEXT: "pycoin", -CHECK-NEXT: "pycritty", -CHECK-NEXT: "pydeps", -CHECK-NEXT: "pydf", -CHECK-NEXT: "pyditz", -CHECK-NEXT: "pyenv", -CHECK-NEXT: "pygmentex", -CHECK-NEXT: "pyinfra", -CHECK-NEXT: "pykms", -CHECK-NEXT: "pylint", -CHECK-NEXT: "pylint-exit", -CHECK-NEXT: "pyload-ng", -CHECK-NEXT: "pylode", -CHECK-NEXT: "pyls-black", -CHECK-NEXT: "pyls-mypy", -CHECK-NEXT: "pylyzer", -CHECK-NEXT: "pymol", -CHECK-NEXT: "pympress", -CHECK-NEXT: "pynac", -CHECK-NEXT: "pynitrokey", -CHECK-NEXT: "pyo3-pack", -CHECK-NEXT: "pyocd", -CHECK-NEXT: "pyotherside", -CHECK-NEXT: "pyp", -CHECK-NEXT: "pypass", -CHECK-NEXT: "pypi-mirror" +CHECK-NEXT: "py1", +CHECK-NEXT: "py2", +CHECK-NEXT: "py3" CHECK-NEXT: ] ``` diff --git a/nixd/tools/nixd-attrset-eval/test/attrs-info.md b/nixd/tools/nixd-attrset-eval/test/attrs-info.md index e84f18287..001e07e07 100644 --- a/nixd/tools/nixd-attrset-eval/test/attrs-info.md +++ b/nixd/tools/nixd-attrset-eval/test/attrs-info.md @@ -6,7 +6,7 @@ "jsonrpc":"2.0", "id":0, "method":"attrset/evalExpr", - "params": "import { }" + "params": "{ hello.meta.description = \"A program that produces a familiar, friendly greeting\"; }" } ``` diff --git a/nixd/tools/nixd-attrset-eval/test/option-complete.md b/nixd/tools/nixd-attrset-eval/test/option-complete.md index 15ddc193e..2e7875626 100644 --- a/nixd/tools/nixd-attrset-eval/test/option-complete.md +++ b/nixd/tools/nixd-attrset-eval/test/option-complete.md @@ -1,12 +1,31 @@ # RUN: nixd-attrset-eval --lit-test < %s | FileCheck %s +```nix +{ + boot.bcache.bar = 1; + boot.binfmt.bar = 1; + boot.binfmtMiscRegistrations = { + _type = "option"; + description = "Alias of {option}`boot.binfmt.registrations`."; + type = { + description = "attribute set of (submodule)"; + name = "attrsOf"; + }; + declarationPositions = [ + { column = 16; file = "/nix/store/43fgdg04gbrjh8ww8q8zgbqxn4sb35py-source/lib/attrsets.nix"; line = 190; } + ]; + }; +} +``` + + ```json { "jsonrpc":"2.0", "id":0, "method":"attrset/evalExpr", - "params": "(let pkgs = import { }; in (pkgs.lib.evalModules { modules = (import ) ++ [ ({...}: { nixpkgs.hostPlatform = builtins.currentSystem;} ) ] ; })).options" + "params": "{\r\n boot.bcache.bar = 1;\r\n boot.binfmt.bar = 1;\r\n boot.binfmtMiscRegistrations = {\r\n _type = \"option\";\r\n description = \"Alias of {option}`boot.binfmt.registrations`.\";\r\n type = {\r\n description = \"attribute set of (submodule)\";\r\n name = \"attrsOf\";\r\n };\r\n declarationPositions = [\r\n { column = 16; file = \"\/nix\/store\/43fgdg04gbrjh8ww8q8zgbqxn4sb35py-source\/lib\/attrsets.nix\"; line = 190; }\r\n ];\r\n };\r\n}" } ``` diff --git a/nixd/tools/nixd-attrset-eval/test/option-info.md b/nixd/tools/nixd-attrset-eval/test/option-info.md index 62a0ea0d6..9ebdd977a 100644 --- a/nixd/tools/nixd-attrset-eval/test/option-info.md +++ b/nixd/tools/nixd-attrset-eval/test/option-info.md @@ -1,28 +1,48 @@ # RUN: nixd-attrset-eval --lit-test < %s | FileCheck %s +```nix +{ + boot.bcache.bar = 1; + boot.binfmt.bar = 1; + boot.binfmtMiscRegistrations = { + _type = "option"; + description = "Alias of {option}`boot.binfmt.registrations`."; + type = { + description = "attribute set of (submodule)"; + name = "attrsOf"; + }; + declarationPositions = [ + { column = 16; file = "/nix/store/43fgdg04gbrjh8ww8q8zgbqxn4sb35py-source/lib/attrsets.nix"; line = 190; } + ]; + }; +} +``` + ```json { "jsonrpc":"2.0", "id":0, "method":"attrset/evalExpr", - "params": "(let pkgs = import { }; in (pkgs.lib.evalModules { modules = (import ) ++ [ ({...}: { nixpkgs.hostPlatform = builtins.currentSystem;} ) ] ; })).options" + "params": "{\r\n boot.bcache.bar = 1;\r\n boot.binfmt.bar = 1;\r\n boot.binfmtMiscRegistrations = {\r\n _type = \"option\";\r\n description = \"Alias of {option}`boot.binfmt.registrations`.\";\r\n type = {\r\n description = \"attribute set of (submodule)\";\r\n name = \"attrsOf\";\r\n };\r\n declarationPositions = [\r\n { column = 16; file = \"\/nix\/store\/43fgdg04gbrjh8ww8q8zgbqxn4sb35py-source\/lib\/attrsets.nix\"; line = 190; }\r\n ];\r\n };\r\n}" } ``` - ```json { "jsonrpc":"2.0", "id":1, "method":"attrset/optionInfo", - "params": [ "boot", "devSize" ] + "params": [ "boot", "binfmtMiscRegistrations" ] } ``` - ``` -CHECK: "Description": "Size limit for the /dev tmpfs. Look at mount(8), tmpfs size option,\nfor the accepted syntax.\n", -CHECK: "Example": "32m" +CHECK: "Description": "Alias of {option}`boot.binfmt.registrations`.", +CHECK-NEXT: "Example": null, +CHECK-NEXT: "Type": { +CHECK-NEXT: "Description": "attribute set of (submodule)", +CHECK-NEXT: "Name": "attrsOf" +CHECK-NEXT: } ``` ```json