Add more input/output type annotations (#7532)

This commit is contained in:
Stefan Holderbach
2022-12-21 20:20:46 +01:00
committed by GitHub
parent d27263af97
commit 4e1f94026c
78 changed files with 324 additions and 186 deletions

View File

@ -1,5 +1,5 @@
use nu_command::create_default_context;
use nu_protocol::engine::StateWorkingSet;
use nu_protocol::{engine::StateWorkingSet, Category};
use quickcheck_macros::quickcheck;
mod commands;
@ -49,6 +49,37 @@ fn signature_name_matches_command_name() {
);
}
#[test]
fn commands_declare_input_output_types() {
let ctx = crate::create_default_context();
let decls = ctx.get_decl_ids_sorted(true);
let mut failures = Vec::new();
for decl_id in decls {
let cmd = ctx.get_decl(decl_id);
let sig_name = cmd.signature().name;
let category = cmd.signature().category;
if matches!(category, Category::Deprecated | Category::Custom(_)) {
// Deprecated commands don't have to conform
// TODO: also upgrade the `--features dataframe` commands
continue;
}
if cmd.signature().input_output_types.is_empty() {
failures.push(format!(
"{sig_name} ({category:?}): No pipeline input/output type signatures found"
));
}
}
assert!(
failures.is_empty(),
"Command missing type annotations:\n{}",
failures.join("\n")
);
}
#[test]
fn no_search_term_duplicates() {
let ctx = crate::create_default_context();