-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
133 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
mod control; | ||
|
||
pub use control::run_tool_on_merge_scenario; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,91 +1,91 @@ | ||
use std::process::Command; | ||
// use std::process::Command; | ||
|
||
use assert_cmd::prelude::*; | ||
// use assert_cmd::prelude::*; | ||
|
||
#[test] | ||
fn it_does_not_crash_and_produces_the_expected_output() { | ||
let mut cmd = Command::cargo_bin("generic-merge").unwrap(); | ||
cmd.arg("--base-path=tests/samples/smoke_java/base.java") | ||
.arg("--left-path=tests/samples/smoke_java/left.java") | ||
.arg("--right-path=tests/samples/smoke_java/right.java") | ||
.arg("--merge-path=tests/samples/smoke_java/merge.output.java") | ||
.assert() | ||
.code(0); | ||
// #[test] | ||
// fn it_does_not_crash_and_produces_the_expected_output() { | ||
// let mut cmd = Command::cargo_bin("generic-merge").unwrap(); | ||
// cmd.arg("--base-path=tests/samples/smoke_java/base.java") | ||
// .arg("--left-path=tests/samples/smoke_java/left.java") | ||
// .arg("--right-path=tests/samples/smoke_java/right.java") | ||
// .arg("--merge-path=tests/samples/smoke_java/merge.output.java") | ||
// .assert() | ||
// .code(0); | ||
|
||
assert_eq!( | ||
std::fs::read_to_string("tests/samples/smoke_java/merge.expected.java").unwrap(), | ||
std::fs::read_to_string("tests/samples/smoke_java/merge.output.java").unwrap() | ||
) | ||
} | ||
// assert_eq!( | ||
// std::fs::read_to_string("tests/samples/smoke_java/merge.expected.java").unwrap(), | ||
// std::fs::read_to_string("tests/samples/smoke_java/merge.output.java").unwrap() | ||
// ) | ||
// } | ||
|
||
#[test] | ||
fn if_left_equals_base_then_output_right_as_result() { | ||
let mut cmd = Command::cargo_bin("generic-merge").unwrap(); | ||
cmd.arg("--base-path=tests/samples/one_parent_equals_base/base.java") | ||
.arg("--left-path=tests/samples/one_parent_equals_base/base.java") | ||
.arg("--right-path=tests/samples/one_parent_equals_base/changed_parent.java") | ||
.arg("--merge-path=tests/samples/one_parent_equals_base/merge.output.right.java") | ||
.assert() | ||
.code(0); | ||
// #[test] | ||
// fn if_left_equals_base_then_output_right_as_result() { | ||
// let mut cmd = Command::cargo_bin("generic-merge").unwrap(); | ||
// cmd.arg("--base-path=tests/samples/one_parent_equals_base/base.java") | ||
// .arg("--left-path=tests/samples/one_parent_equals_base/base.java") | ||
// .arg("--right-path=tests/samples/one_parent_equals_base/changed_parent.java") | ||
// .arg("--merge-path=tests/samples/one_parent_equals_base/merge.output.right.java") | ||
// .assert() | ||
// .code(0); | ||
|
||
assert_eq!( | ||
std::fs::read_to_string("tests/samples/one_parent_equals_base/changed_parent.java") | ||
.unwrap(), | ||
std::fs::read_to_string("tests/samples/one_parent_equals_base/merge.output.right.java") | ||
.unwrap() | ||
) | ||
} | ||
// assert_eq!( | ||
// std::fs::read_to_string("tests/samples/one_parent_equals_base/changed_parent.java") | ||
// .unwrap(), | ||
// std::fs::read_to_string("tests/samples/one_parent_equals_base/merge.output.right.java") | ||
// .unwrap() | ||
// ) | ||
// } | ||
|
||
#[test] | ||
fn if_right_equals_base_then_output_left_as_result() { | ||
let mut cmd = Command::cargo_bin("generic-merge").unwrap(); | ||
cmd.arg("--base-path=tests/samples/one_parent_equals_base/base.java") | ||
.arg("--left-path=tests/samples/one_parent_equals_base/base.java") | ||
.arg("--right-path=tests/samples/one_parent_equals_base/changed_parent.java") | ||
.arg("--merge-path=tests/samples/one_parent_equals_base/merge.output.left.java") | ||
.assert() | ||
.code(0); | ||
// #[test] | ||
// fn if_right_equals_base_then_output_left_as_result() { | ||
// let mut cmd = Command::cargo_bin("generic-merge").unwrap(); | ||
// cmd.arg("--base-path=tests/samples/one_parent_equals_base/base.java") | ||
// .arg("--left-path=tests/samples/one_parent_equals_base/base.java") | ||
// .arg("--right-path=tests/samples/one_parent_equals_base/changed_parent.java") | ||
// .arg("--merge-path=tests/samples/one_parent_equals_base/merge.output.left.java") | ||
// .assert() | ||
// .code(0); | ||
|
||
assert_eq!( | ||
std::fs::read_to_string("tests/samples/one_parent_equals_base/changed_parent.java") | ||
.unwrap(), | ||
std::fs::read_to_string("tests/samples/one_parent_equals_base/merge.output.left.java") | ||
.unwrap() | ||
) | ||
} | ||
// assert_eq!( | ||
// std::fs::read_to_string("tests/samples/one_parent_equals_base/changed_parent.java") | ||
// .unwrap(), | ||
// std::fs::read_to_string("tests/samples/one_parent_equals_base/merge.output.left.java") | ||
// .unwrap() | ||
// ) | ||
// } | ||
|
||
#[test] | ||
fn it_works_on_semi_structured_merge() { | ||
run_tool_on_scenario("semi_structured") | ||
} | ||
// #[test] | ||
// fn it_works_on_semi_structured_merge() { | ||
// run_tool_on_scenario("semi_structured") | ||
// } | ||
|
||
#[test] | ||
fn it_works_on_node_reordering() { | ||
run_tool_on_scenario("node_reordering") | ||
} | ||
// #[test] | ||
// fn it_works_on_node_reordering() { | ||
// run_tool_on_scenario("node_reordering") | ||
// } | ||
|
||
#[test] | ||
fn it_works_on_no_conflicts() { | ||
run_tool_on_scenario("no_conflicts") | ||
} | ||
// #[test] | ||
// fn it_works_on_no_conflicts() { | ||
// run_tool_on_scenario("no_conflicts") | ||
// } | ||
|
||
fn run_tool_on_scenario(scenario_name: &str) { | ||
let mut cmd = Command::cargo_bin("generic-merge").unwrap(); | ||
cmd.arg(format!("-b=tests/samples/{}/base.java", scenario_name)) | ||
.arg(format!("-l=tests/samples/{}/left.java", scenario_name)) | ||
.arg(format!("-r=tests/samples/{}/right.java", scenario_name)) | ||
.arg(format!( | ||
"-m=tests/samples/{}/merge.output.java", | ||
scenario_name | ||
)) | ||
.assert() | ||
.code(0); | ||
// fn run_tool_on_scenario(scenario_name: &str) { | ||
// let mut cmd = Command::cargo_bin("generic-merge").unwrap(); | ||
// cmd.arg(format!("-b=tests/samples/{}/base.java", scenario_name)) | ||
// .arg(format!("-l=tests/samples/{}/left.java", scenario_name)) | ||
// .arg(format!("-r=tests/samples/{}/right.java", scenario_name)) | ||
// .arg(format!( | ||
// "-m=tests/samples/{}/merge.output.java", | ||
// scenario_name | ||
// )) | ||
// .assert() | ||
// .code(0); | ||
|
||
let expected_result_path = format!("tests/samples/{}/merge.expected.java", scenario_name); | ||
let actual_result_path = format!("tests/samples/{}/merge.output.java", scenario_name); | ||
// let expected_result_path = format!("tests/samples/{}/merge.expected.java", scenario_name); | ||
// let actual_result_path = format!("tests/samples/{}/merge.output.java", scenario_name); | ||
|
||
assert_eq!( | ||
std::fs::read_to_string(expected_result_path).unwrap(), | ||
std::fs::read_to_string(actual_result_path).unwrap() | ||
) | ||
} | ||
// assert_eq!( | ||
// std::fs::read_to_string(expected_result_path).unwrap(), | ||
// std::fs::read_to_string(actual_result_path).unwrap() | ||
// ) | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#[test] | ||
fn all_java_samples_work_correctly() -> Result<(), Box<dyn std::error::Error>> { | ||
let sample_names = get_samples_names()?; | ||
|
||
for sample_path in sample_names { | ||
let base = std::fs::read_to_string(format!("{}/base.java", sample_path.display()))?; | ||
let left = std::fs::read_to_string(format!("{}/left.java", sample_path.display()))?; | ||
let right = std::fs::read_to_string(format!("{}/right.java", sample_path.display()))?; | ||
|
||
let expected = std::fs::read_to_string(format!("{}/merge.java", sample_path.display()))?; | ||
let result = bin::run_tool_on_merge_scenario(model::Language::Java, &base, &left, &right)?; | ||
|
||
assert_eq!(expected, result.to_string()) | ||
} | ||
|
||
Ok(()) | ||
} | ||
|
||
fn get_samples_names() -> Result<Vec<std::path::PathBuf>, std::io::Error> { | ||
std::fs::read_dir("tests/samples")? | ||
.into_iter() | ||
.filter(|sample| { | ||
sample | ||
.as_ref() | ||
.map(|sample| sample.path().is_dir()) | ||
.unwrap_or(false) | ||
}) | ||
.map(|sample| sample.map(|sample| sample.path())) | ||
.collect() | ||
} |
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.