mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-27 19:17:43 +00:00
pr: add first test
This commit is contained in:
parent
f799d22b7d
commit
629236bd39
4 changed files with 165 additions and 0 deletions
|
@ -127,6 +127,15 @@ impl CmdResult {
|
|||
let contents = read_scenario_fixture(&self.tmpd, file_rel_path);
|
||||
self.stdout_is(contents)
|
||||
}
|
||||
/// like stdout_is_fixture(...), but replaces the data in fixture file based on values provided in template_vars
|
||||
/// command output
|
||||
pub fn stdout_is_templated_fixture<T: AsRef<OsStr>>(&self, file_rel_path: T, template_vars: Vec<(String, String)>) -> Box<&CmdResult> {
|
||||
let mut contents = read_scenario_fixture(&self.tmpd, file_rel_path);
|
||||
for kv in template_vars {
|
||||
contents = contents.replace(&kv.0, &kv.1);
|
||||
}
|
||||
self.stdout_is(contents)
|
||||
}
|
||||
|
||||
/// asserts that the command resulted in stderr stream output that equals the
|
||||
/// passed in value, when both are trimmed of trailing whitespace
|
||||
|
@ -615,6 +624,11 @@ impl UCommand {
|
|||
cmd_result.failure();
|
||||
cmd_result
|
||||
}
|
||||
|
||||
pub fn get_full_fixture_path(&self, file_rel_path: &str) -> String{
|
||||
let tmpdir_path = self.tmpd.as_ref().unwrap().path();
|
||||
format!("{}/{}", tmpdir_path.to_str().unwrap(), file_rel_path)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn read_size(child: &mut Child, size: usize) -> String {
|
||||
|
|
56
tests/fixtures/pr/test_one_page.log
vendored
Normal file
56
tests/fixtures/pr/test_one_page.log
vendored
Normal file
|
@ -0,0 +1,56 @@
|
|||
ntation processAirPortStateChanges]: pppConnectionState 0
|
||||
Mon Dec 10 11:42:56.558 Info: <Wi-Fi Menu Extra[335]> -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars
|
||||
Mon Dec 10 11:42:56.705 Info: <Wi-Fi Menu Extra[335]> 802.1X changed
|
||||
Mon Dec 10 11:42:56.706 Info: <Wi-Fi Menu Extra[335]> -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0
|
||||
Mon Dec 10 11:42:56.706 Info: <Wi-Fi Menu Extra[335]> -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars
|
||||
Mon Dec 10 11:42:56.854 Info: <Wi-Fi Menu Extra[335]> 802.1X changed
|
||||
Mon Dec 10 11:42:56.855 Info: <Wi-Fi Menu Extra[335]> -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0
|
||||
Mon Dec 10 11:42:56.856 Info: <Wi-Fi Menu Extra[335]> -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars
|
||||
Mon Dec 10 11:42:57.002 Info: <Wi-Fi Menu Extra[335]> 802.1X changed
|
||||
Mon Dec 10 11:42:57.003 Info: <Wi-Fi Menu Extra[335]> -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0
|
||||
Mon Dec 10 11:42:57.003 Info: <Wi-Fi Menu Extra[335]> -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars
|
||||
Mon Dec 10 11:42:57.152 Info: <Wi-Fi Menu Extra[335]> 802.1X changed
|
||||
Mon Dec 10 11:42:57.154 Info: <Wi-Fi Menu Extra[335]> -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0
|
||||
Mon Dec 10 11:42:57.154 Info: <Wi-Fi Menu Extra[335]> -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars
|
||||
Mon Dec 10 11:42:57.302 Info: <Wi-Fi Menu Extra[335]> 802.1X changed
|
||||
Mon Dec 10 11:42:57.304 Info: <Wi-Fi Menu Extra[335]> -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0
|
||||
Mon Dec 10 11:42:57.304 Info: <Wi-Fi Menu Extra[335]> -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars
|
||||
Mon Dec 10 11:42:57.449 Info: <Wi-Fi Menu Extra[335]> 802.1X changed
|
||||
Mon Dec 10 11:42:57.451 Info: <Wi-Fi Menu Extra[335]> -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0
|
||||
Mon Dec 10 11:42:57.451 Info: <Wi-Fi Menu Extra[335]> -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars
|
||||
Mon Dec 10 11:42:57.600 Info: <Wi-Fi Menu Extra[335]> 802.1X changed
|
||||
Mon Dec 10 11:42:57.601 Info: <Wi-Fi Menu Extra[335]> -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0
|
||||
Mon Dec 10 11:42:57.602 Info: <Wi-Fi Menu Extra[335]> -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars
|
||||
Mon Dec 10 11:42:57.624 Info: <Wi-Fi Menu Extra[335]> -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0
|
||||
Mon Dec 10 11:42:57.624 Info: <Wi-Fi Menu Extra[335]> -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars
|
||||
Mon Dec 10 11:42:57.749 Info: <Wi-Fi Menu Extra[335]> 802.1X changed
|
||||
Mon Dec 10 11:42:57.750 Info: <Wi-Fi Menu Extra[335]> -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0
|
||||
Mon Dec 10 11:42:57.751 Info: <Wi-Fi Menu Extra[335]> -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars
|
||||
Mon Dec 10 11:42:57.896 Info: <Wi-Fi Menu Extra[335]> 802.1X changed
|
||||
Mon Dec 10 11:42:57.897 Info: <Wi-Fi Menu Extra[335]> -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0
|
||||
Mon Dec 10 11:42:57.897 Info: <Wi-Fi Menu Extra[335]> -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars
|
||||
Mon Dec 10 11:42:58.045 Info: <Wi-Fi Menu Extra[335]> 802.1X changed
|
||||
Mon Dec 10 11:42:58.047 Info: <Wi-Fi Menu Extra[335]> -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0
|
||||
Mon Dec 10 11:42:58.047 Info: <Wi-Fi Menu Extra[335]> -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars
|
||||
Mon Dec 10 11:42:58.193 Info: <Wi-Fi Menu Extra[335]> 802.1X changed
|
||||
Mon Dec 10 11:42:58.195 Info: <Wi-Fi Menu Extra[335]> -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0
|
||||
Mon Dec 10 11:42:58.195 Info: <Wi-Fi Menu Extra[335]> -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars
|
||||
Mon Dec 10 11:42:58.342 Info: <Wi-Fi Menu Extra[335]> 802.1X changed
|
||||
Mon Dec 10 11:42:58.343 Info: <Wi-Fi Menu Extra[335]> -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0
|
||||
Mon Dec 10 11:42:58.344 Info: <Wi-Fi Menu Extra[335]> -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars
|
||||
Mon Dec 10 11:42:58.491 Info: <Wi-Fi Menu Extra[335]> 802.1X changed
|
||||
Mon Dec 10 11:42:58.493 Info: <Wi-Fi Menu Extra[335]> -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0
|
||||
Mon Dec 10 11:42:58.494 Info: <Wi-Fi Menu Extra[335]> -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars
|
||||
Mon Dec 10 11:42:58.640 Info: <Wi-Fi Menu Extra[335]> 802.1X changed
|
||||
Mon Dec 10 11:42:58.642 Info: <Wi-Fi Menu Extra[335]> -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0
|
||||
Mon Dec 10 11:42:58.642 Info: <Wi-Fi Menu Extra[335]> -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars
|
||||
Mon Dec 10 11:42:58.805 Info: <Wi-Fi Menu Extra[335]> 802.1X changed
|
||||
Mon Dec 10 11:42:58.806 Info: <Wi-Fi Menu Extra[335]> -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0
|
||||
Mon Dec 10 11:42:58.806 Info: <Wi-Fi Menu Extra[335]> -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars
|
||||
Mon Dec 10 11:42:58.958 Info: <Wi-Fi Menu Extra[335]> 802.1X changed
|
||||
Mon Dec 10 11:42:58.959 Info: <Wi-Fi Menu Extra[335]> -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0
|
||||
Mon Dec 10 11:42:58.960 Info: <Wi-Fi Menu Extra[335]> -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars
|
||||
Mon Dec 10 11:42:59.155 Info: <Wi-Fi Menu Extra[335]> 802.1X changed
|
||||
Mon Dec 10 11:42:59.157 Info: <Wi-Fi Menu Extra[335]> -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0
|
||||
Mon Dec 10 11:42:59.159 Info: <Wi-Fi Menu Extra[335]> -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars
|
||||
Mon Dec 10 11:42:59.352 Info: <Wi-Fi Menu Extra[335]> 802.1X changed
|
66
tests/fixtures/pr/test_one_page.log.expected
vendored
Normal file
66
tests/fixtures/pr/test_one_page.log.expected
vendored
Normal file
|
@ -0,0 +1,66 @@
|
|||
|
||||
|
||||
{last_modified_time} test_one_page.log Page 1
|
||||
|
||||
|
||||
ntation processAirPortStateChanges]: pppConnectionState 0
|
||||
Mon Dec 10 11:42:56.558 Info: <Wi-Fi Menu Extra[335]> -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars
|
||||
Mon Dec 10 11:42:56.705 Info: <Wi-Fi Menu Extra[335]> 802.1X changed
|
||||
Mon Dec 10 11:42:56.706 Info: <Wi-Fi Menu Extra[335]> -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0
|
||||
Mon Dec 10 11:42:56.706 Info: <Wi-Fi Menu Extra[335]> -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars
|
||||
Mon Dec 10 11:42:56.854 Info: <Wi-Fi Menu Extra[335]> 802.1X changed
|
||||
Mon Dec 10 11:42:56.855 Info: <Wi-Fi Menu Extra[335]> -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0
|
||||
Mon Dec 10 11:42:56.856 Info: <Wi-Fi Menu Extra[335]> -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars
|
||||
Mon Dec 10 11:42:57.002 Info: <Wi-Fi Menu Extra[335]> 802.1X changed
|
||||
Mon Dec 10 11:42:57.003 Info: <Wi-Fi Menu Extra[335]> -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0
|
||||
Mon Dec 10 11:42:57.003 Info: <Wi-Fi Menu Extra[335]> -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars
|
||||
Mon Dec 10 11:42:57.152 Info: <Wi-Fi Menu Extra[335]> 802.1X changed
|
||||
Mon Dec 10 11:42:57.154 Info: <Wi-Fi Menu Extra[335]> -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0
|
||||
Mon Dec 10 11:42:57.154 Info: <Wi-Fi Menu Extra[335]> -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars
|
||||
Mon Dec 10 11:42:57.302 Info: <Wi-Fi Menu Extra[335]> 802.1X changed
|
||||
Mon Dec 10 11:42:57.304 Info: <Wi-Fi Menu Extra[335]> -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0
|
||||
Mon Dec 10 11:42:57.304 Info: <Wi-Fi Menu Extra[335]> -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars
|
||||
Mon Dec 10 11:42:57.449 Info: <Wi-Fi Menu Extra[335]> 802.1X changed
|
||||
Mon Dec 10 11:42:57.451 Info: <Wi-Fi Menu Extra[335]> -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0
|
||||
Mon Dec 10 11:42:57.451 Info: <Wi-Fi Menu Extra[335]> -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars
|
||||
Mon Dec 10 11:42:57.600 Info: <Wi-Fi Menu Extra[335]> 802.1X changed
|
||||
Mon Dec 10 11:42:57.601 Info: <Wi-Fi Menu Extra[335]> -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0
|
||||
Mon Dec 10 11:42:57.602 Info: <Wi-Fi Menu Extra[335]> -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars
|
||||
Mon Dec 10 11:42:57.624 Info: <Wi-Fi Menu Extra[335]> -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0
|
||||
Mon Dec 10 11:42:57.624 Info: <Wi-Fi Menu Extra[335]> -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars
|
||||
Mon Dec 10 11:42:57.749 Info: <Wi-Fi Menu Extra[335]> 802.1X changed
|
||||
Mon Dec 10 11:42:57.750 Info: <Wi-Fi Menu Extra[335]> -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0
|
||||
Mon Dec 10 11:42:57.751 Info: <Wi-Fi Menu Extra[335]> -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars
|
||||
Mon Dec 10 11:42:57.896 Info: <Wi-Fi Menu Extra[335]> 802.1X changed
|
||||
Mon Dec 10 11:42:57.897 Info: <Wi-Fi Menu Extra[335]> -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0
|
||||
Mon Dec 10 11:42:57.897 Info: <Wi-Fi Menu Extra[335]> -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars
|
||||
Mon Dec 10 11:42:58.045 Info: <Wi-Fi Menu Extra[335]> 802.1X changed
|
||||
Mon Dec 10 11:42:58.047 Info: <Wi-Fi Menu Extra[335]> -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0
|
||||
Mon Dec 10 11:42:58.047 Info: <Wi-Fi Menu Extra[335]> -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars
|
||||
Mon Dec 10 11:42:58.193 Info: <Wi-Fi Menu Extra[335]> 802.1X changed
|
||||
Mon Dec 10 11:42:58.195 Info: <Wi-Fi Menu Extra[335]> -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0
|
||||
Mon Dec 10 11:42:58.195 Info: <Wi-Fi Menu Extra[335]> -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars
|
||||
Mon Dec 10 11:42:58.342 Info: <Wi-Fi Menu Extra[335]> 802.1X changed
|
||||
Mon Dec 10 11:42:58.343 Info: <Wi-Fi Menu Extra[335]> -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0
|
||||
Mon Dec 10 11:42:58.344 Info: <Wi-Fi Menu Extra[335]> -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars
|
||||
Mon Dec 10 11:42:58.491 Info: <Wi-Fi Menu Extra[335]> 802.1X changed
|
||||
Mon Dec 10 11:42:58.493 Info: <Wi-Fi Menu Extra[335]> -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0
|
||||
Mon Dec 10 11:42:58.494 Info: <Wi-Fi Menu Extra[335]> -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars
|
||||
Mon Dec 10 11:42:58.640 Info: <Wi-Fi Menu Extra[335]> 802.1X changed
|
||||
Mon Dec 10 11:42:58.642 Info: <Wi-Fi Menu Extra[335]> -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0
|
||||
Mon Dec 10 11:42:58.642 Info: <Wi-Fi Menu Extra[335]> -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars
|
||||
Mon Dec 10 11:42:58.805 Info: <Wi-Fi Menu Extra[335]> 802.1X changed
|
||||
Mon Dec 10 11:42:58.806 Info: <Wi-Fi Menu Extra[335]> -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0
|
||||
Mon Dec 10 11:42:58.806 Info: <Wi-Fi Menu Extra[335]> -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars
|
||||
Mon Dec 10 11:42:58.958 Info: <Wi-Fi Menu Extra[335]> 802.1X changed
|
||||
Mon Dec 10 11:42:58.959 Info: <Wi-Fi Menu Extra[335]> -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0
|
||||
Mon Dec 10 11:42:58.960 Info: <Wi-Fi Menu Extra[335]> -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars
|
||||
Mon Dec 10 11:42:59.155 Info: <Wi-Fi Menu Extra[335]> 802.1X changed
|
||||
Mon Dec 10 11:42:59.157 Info: <Wi-Fi Menu Extra[335]> -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0
|
||||
Mon Dec 10 11:42:59.159 Info: <Wi-Fi Menu Extra[335]> -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars
|
||||
Mon Dec 10 11:42:59.352 Info: <Wi-Fi Menu Extra[335]> 802.1X changed
|
||||
|
||||
|
||||
|
||||
|
||||
|
29
tests/test_pr.rs
Normal file
29
tests/test_pr.rs
Normal file
|
@ -0,0 +1,29 @@
|
|||
extern crate chrono;
|
||||
|
||||
use common::util::*;
|
||||
use std::fs::metadata;
|
||||
use test_pr::chrono::DateTime;
|
||||
use test_pr::chrono::offset::Local;
|
||||
|
||||
fn file_last_modified_time(ucmd: &UCommand, path: &str) -> String {
|
||||
let tmp_dir_path = ucmd.get_full_fixture_path(path);
|
||||
let file_metadata = metadata(tmp_dir_path);
|
||||
return file_metadata.map(|i| {
|
||||
return i.modified().map(|x| {
|
||||
let datetime: DateTime<Local> = x.into();
|
||||
datetime.format("%b %d %H:%M %Y").to_string()
|
||||
}).unwrap_or(String::new());
|
||||
}).unwrap_or(String::new());
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn test_output_multi_files_print_all_chars() {
|
||||
let test_file_path = "test_one_page.log";
|
||||
let mut scenario = new_ucmd!();
|
||||
let value = file_last_modified_time(&scenario, test_file_path);
|
||||
scenario
|
||||
.args(&["test_one_page.log"])
|
||||
.succeeds()
|
||||
.stdout_is_templated_fixture("test_one_page.log.expected", vec![("{last_modified_time}".to_string(), value)]);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue