blob: 4fe9a94549d57d2799768bdb82b40730fa2aa941 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
//! ref: composer/tests/Composer/Test/DocumentationTest.php
use std::cell::RefCell;
use std::rc::Rc;
use shirabe::console::application::ApplicationHandle;
use shirabe_external_packages::symfony::console::command::Command;
use shirabe_external_packages::symfony::console::descriptor::application_description::ApplicationDescription;
fn get_command_name(command: &Rc<RefCell<dyn Command>>) -> String {
let mut name = command.borrow().get_name().unwrap_or_default();
for alias in command.borrow().get_aliases() {
name = format!("{} / {}", name, alias);
}
name
}
fn provide_command_cases() -> Vec<Rc<RefCell<dyn Command>>> {
let application = ApplicationHandle::new("Composer".to_string(), "".to_string()).unwrap();
application.set_catch_exceptions(false);
let mut description =
ApplicationDescription::new(application.__base_application(), None, false);
let mut commands = Vec::new();
for command in description.get_commands().values() {
if ["about", "completion", "list"]
.contains(&command.borrow().get_name().as_deref().unwrap_or(""))
{
continue;
}
commands.push(command.clone());
}
commands
}
#[test]
fn test_command() {
let doc_content = std::fs::read_to_string(format!(
"{}/../../composer/doc/03-cli.md",
env!("CARGO_MANIFEST_DIR")
))
.unwrap();
for command in provide_command_cases() {
assert!(
// TODO: test description
// TODO: test options
doc_content.contains(&format!("\n## {}\n\n", get_command_name(&command))),
"doc/03-cli.md does not contain a section for command \"{}\"",
get_command_name(&command),
);
}
}
|