Skip to content

Commit

Permalink
feat(psa): sub module content root detect.
Browse files Browse the repository at this point in the history
  • Loading branch information
ynfeng committed Feb 26, 2021
1 parent b213273 commit 969f461
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 1 deletion.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
1 change: 1 addition & 0 deletions psa/src/jvm/maven_module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ impl MavenModuleAnalyzer {
fn detect_sub_modules(&self, module_path: &str, module: &mut Option<Module>) {
let sub_modules = &mut self.analysis_sub_modules(module_path);
module.as_mut().unwrap().add_sub_modules(sub_modules);
self.detect_content_root(module_path, module);
}

fn analysis_sub_modules(&self, module_path: &str) -> Vec<Module> {
Expand Down
42 changes: 41 additions & 1 deletion psa/src/jvm/psa_jvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ mod tests {
}

#[test]
fn should_detect_project_model_content_root() {
fn should_detect_project_module_content_root() {
let project = do_analysis(vec![
"_fixtures",
"projects",
Expand Down Expand Up @@ -173,6 +173,46 @@ mod tests {
);
}

#[test]
fn should_detect_sub_module_content_root() {
let project = do_analysis(vec![
"_fixtures",
"projects",
"java",
"multi_mod_maven_project",
]);

let modules = project.modules;
let project_module = modules.get(0).unwrap();
let module1 = project_module.sub_modules.get(0).unwrap();
let content_root = &module1.content_root;

let expect_source_path = join_path(module1.path.as_str(), vec!["src", "main", "java"]);
assert_eq!(
content_root.source_root.get(0).unwrap().as_str(),
expect_source_path
);

let expect_test_source_root = join_path(module1.path.as_str(), vec!["src", "test", "java"]);
assert_eq!(
content_root.test_source_root.get(0).unwrap().as_str(),
expect_test_source_root.as_str()
);

let expect_test_source_root = join_path(module1.path.as_str(), vec!["src", "test", "java"]);
assert_eq!(
content_root.test_source_root.get(0).unwrap().as_str(),
expect_test_source_root.as_str()
);

let expect_test_resources_root =
join_path(module1.path.as_str(), vec!["src", "test", "resources"]);
assert_eq!(
content_root.test_resource_root.get(0).unwrap(),
expect_test_resources_root.as_str()
);
}

fn do_analysis(path: Vec<&str>) -> Project {
let mut project_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.parent()
Expand Down

0 comments on commit 969f461

Please sign in to comment.