just do everything i guess
This commit is contained in:
parent
1e7b7d1614
commit
34ae680e69
5 changed files with 277 additions and 22 deletions
|
|
@ -500,6 +500,52 @@ Options:
|
|||
* here we just verify the parser extracts it correctly. *)
|
||||
check "has entries too" (List.length r.entries >= 2)
|
||||
|
||||
let test_nu_file_parsing () =
|
||||
Printf.printf "\n== .nu file parsing ==\n";
|
||||
let nu_source = {|module completions {
|
||||
|
||||
# Unofficial CLI tool
|
||||
export extern mytool [
|
||||
--help(-h) # Print help
|
||||
--version(-V) # Print version
|
||||
]
|
||||
|
||||
# List all items
|
||||
export extern "mytool list" [
|
||||
--raw # Output as JSON
|
||||
--format(-f): string # Output format
|
||||
--help(-h) # Print help
|
||||
name?: string # Filter by name
|
||||
]
|
||||
|
||||
}
|
||||
|
||||
use completions *
|
||||
|} in
|
||||
let r = Inshellah.Store.parse_nu_completions "mytool" nu_source in
|
||||
check "has entries" (List.length r.entries = 2);
|
||||
check "has subcommands" (List.length r.subcommands >= 1);
|
||||
let list_sc = List.find_opt (fun (sc : subcommand) -> sc.name = "list") r.subcommands in
|
||||
check "has list subcommand" (list_sc <> None);
|
||||
check "description" (r.description = "Unofficial CLI tool");
|
||||
(* test subcommand lookup *)
|
||||
let r2 = Inshellah.Store.parse_nu_completions "mytool list" nu_source in
|
||||
check "list has entries" (List.length r2.entries = 3);
|
||||
let has_format = List.exists (fun (e : entry) ->
|
||||
e.switch = Both ('f', "format")) r2.entries in
|
||||
check "list has --format(-f)" has_format;
|
||||
check "list has positional" (List.length r2.positionals >= 1)
|
||||
|
||||
let test_italic_synopsis () =
|
||||
Printf.printf "\n== Italic in SYNOPSIS ==\n";
|
||||
let groff = {|.SH Synopsis
|
||||
.LP
|
||||
\f(CRnix-env\fR \fIoperation\fR [\fIoptions\fR] [\fIarguments…\fR]
|
||||
.SH Description
|
||||
|} in
|
||||
let cmd = extract_synopsis_command groff in
|
||||
check "no phantom operation" (cmd = Some "nix-env")
|
||||
|
||||
let test_font_boundary_spacing () =
|
||||
Printf.printf "\n== Font boundary spacing ==\n";
|
||||
(* \fB--max-results\fR\fIcount\fR should become "--max-results count" *)
|
||||
|
|
@ -556,5 +602,9 @@ let () =
|
|||
test_commands_section_subcommands ();
|
||||
test_self_listing_detection ();
|
||||
|
||||
Printf.printf "\nRunning .nu and synopsis tests...\n";
|
||||
test_nu_file_parsing ();
|
||||
test_italic_synopsis ();
|
||||
|
||||
Printf.printf "\n=== Results: %d passed, %d failed ===\n" !passes !failures;
|
||||
if !failures > 0 then exit 1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue