From b578bb6563e01da21c97f7987d51dda1b3f74840 Mon Sep 17 00:00:00 2001 From: Tilak Patidar Date: Sun, 16 Dec 2018 22:54:09 +0530 Subject: [PATCH] pr: add test for -t -l -r option pr: Add test for -l option pr: Add test for -r suppress error option --- src/pr/pr.rs | 24 ++- .../pr/test_one_page_no_ht.log.expected | 56 +++++ .../fixtures/pr/test_page_length.log.expected | 200 ++++++++++++++++++ .../pr/test_page_length1.log.expected | 10 + tests/test_pr.rs | 49 ++++- 5 files changed, 327 insertions(+), 12 deletions(-) create mode 100644 tests/fixtures/pr/test_one_page_no_ht.log.expected create mode 100644 tests/fixtures/pr/test_page_length.log.expected create mode 100644 tests/fixtures/pr/test_page_length1.log.expected diff --git a/src/pr/pr.rs b/src/pr/pr.rs index 08681c0de..1cc81bfe2 100644 --- a/src/pr/pr.rs +++ b/src/pr/pr.rs @@ -302,7 +302,7 @@ pub fn uumain(args: Vec) -> i32 { let maybe_file = matches.opt_str(NUMBERING_MODE_OPTION).unwrap(); let is_afile = is_a_file(&maybe_file); if !is_afile { - writeln!(&mut stderr(), "{}", PrError::NotExists(maybe_file)); + print_error(&matches, PrError::NotExists(maybe_file)); return 1; } else { files.push(maybe_file); @@ -321,15 +321,13 @@ pub fn uumain(args: Vec) -> i32 { for f in files { let result_options = build_options(&matches, &f); if result_options.is_err() { - writeln!(&mut stderr(), "{}", result_options.err().unwrap()); + print_error(&matches, result_options.err().unwrap()); return 1; } let options = &result_options.unwrap(); let status: i32 = match pr(&f, options) { Err(error) => { - if !options.suppress_errors { - writeln!(&mut stderr(), "{}", error); - } + print_error(&matches, error); 1 } _ => 0 @@ -345,6 +343,12 @@ fn is_a_file(could_be_file: &String) -> bool { File::open(could_be_file).is_ok() } +fn print_error(matches: &Matches, err: PrError) { + if !matches.opt_present(SUPPRESS_PRINTING_ERROR) { + writeln!(&mut stderr(), "{}", err); + } +} + fn print_usage(opts: &mut Options, matches: &Matches) -> i32 { println!("{} {} -- print files", NAME, VERSION); println!(); @@ -476,11 +480,15 @@ fn build_options(matches: &Matches, path: &String) -> Result res?, _ => LINES_PER_PAGE }; + let page_length_le_ht = page_length < (HEADER_LINES_PER_PAGE + TRAILER_LINES_PER_PAGE); - let content_lines_per_page = page_length - (HEADER_LINES_PER_PAGE + TRAILER_LINES_PER_PAGE); + let display_header_and_trailer = !(page_length_le_ht) && !matches.opt_present(NO_HEADER_TRAILER_OPTION); - let display_header_and_trailer = !(page_length < (HEADER_LINES_PER_PAGE + TRAILER_LINES_PER_PAGE)) - && !matches.opt_present(NO_HEADER_TRAILER_OPTION); + let content_lines_per_page = if page_length_le_ht { + page_length + } else { + page_length - (HEADER_LINES_PER_PAGE + TRAILER_LINES_PER_PAGE) + }; let suppress_errors = matches.opt_present(SUPPRESS_PRINTING_ERROR); diff --git a/tests/fixtures/pr/test_one_page_no_ht.log.expected b/tests/fixtures/pr/test_one_page_no_ht.log.expected new file mode 100644 index 000000000..3d5131358 --- /dev/null +++ b/tests/fixtures/pr/test_one_page_no_ht.log.expected @@ -0,0 +1,56 @@ +ntation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:56.558 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:56.705 Info: 802.1X changed +Mon Dec 10 11:42:56.706 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:56.706 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:56.854 Info: 802.1X changed +Mon Dec 10 11:42:56.855 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:56.856 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.002 Info: 802.1X changed +Mon Dec 10 11:42:57.003 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.003 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.152 Info: 802.1X changed +Mon Dec 10 11:42:57.154 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.154 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.302 Info: 802.1X changed +Mon Dec 10 11:42:57.304 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.304 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.449 Info: 802.1X changed +Mon Dec 10 11:42:57.451 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.451 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.600 Info: 802.1X changed +Mon Dec 10 11:42:57.601 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.602 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.624 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.624 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.749 Info: 802.1X changed +Mon Dec 10 11:42:57.750 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.751 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:57.896 Info: 802.1X changed +Mon Dec 10 11:42:57.897 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:57.897 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.045 Info: 802.1X changed +Mon Dec 10 11:42:58.047 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.047 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.193 Info: 802.1X changed +Mon Dec 10 11:42:58.195 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.195 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.342 Info: 802.1X changed +Mon Dec 10 11:42:58.343 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.344 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.491 Info: 802.1X changed +Mon Dec 10 11:42:58.493 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.494 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.640 Info: 802.1X changed +Mon Dec 10 11:42:58.642 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.642 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.805 Info: 802.1X changed +Mon Dec 10 11:42:58.806 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.806 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:58.958 Info: 802.1X changed +Mon Dec 10 11:42:58.959 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:58.960 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:59.155 Info: 802.1X changed +Mon Dec 10 11:42:59.157 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 +Mon Dec 10 11:42:59.159 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars +Mon Dec 10 11:42:59.352 Info: 802.1X changed \ No newline at end of file diff --git a/tests/fixtures/pr/test_page_length.log.expected b/tests/fixtures/pr/test_page_length.log.expected new file mode 100644 index 000000000..02425a8e6 --- /dev/null +++ b/tests/fixtures/pr/test_page_length.log.expected @@ -0,0 +1,200 @@ + + +{last_modified_time} test.log Page 2 + + + 1 ntation processAirPortStateChanges]: pppConnectionState 0 + 2 Mon Dec 10 11:42:56.558 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 3 Mon Dec 10 11:42:56.705 Info: 802.1X changed + 4 Mon Dec 10 11:42:56.706 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 5 Mon Dec 10 11:42:56.706 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 6 Mon Dec 10 11:42:56.854 Info: 802.1X changed + 7 Mon Dec 10 11:42:56.855 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 8 Mon Dec 10 11:42:56.856 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 9 Mon Dec 10 11:42:57.002 Info: 802.1X changed + 10 Mon Dec 10 11:42:57.003 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 11 Mon Dec 10 11:42:57.003 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 12 Mon Dec 10 11:42:57.152 Info: 802.1X changed + 13 Mon Dec 10 11:42:57.154 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 14 Mon Dec 10 11:42:57.154 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 15 Mon Dec 10 11:42:57.302 Info: 802.1X changed + 16 Mon Dec 10 11:42:57.304 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 17 Mon Dec 10 11:42:57.304 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 18 Mon Dec 10 11:42:57.449 Info: 802.1X changed + 19 Mon Dec 10 11:42:57.451 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 20 Mon Dec 10 11:42:57.451 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 21 Mon Dec 10 11:42:57.600 Info: 802.1X changed + 22 Mon Dec 10 11:42:57.601 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 23 Mon Dec 10 11:42:57.602 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 24 Mon Dec 10 11:42:57.624 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 25 Mon Dec 10 11:42:57.624 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 26 Mon Dec 10 11:42:57.749 Info: 802.1X changed + 27 Mon Dec 10 11:42:57.750 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 28 Mon Dec 10 11:42:57.751 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 29 Mon Dec 10 11:42:57.896 Info: 802.1X changed + 30 Mon Dec 10 11:42:57.897 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 31 Mon Dec 10 11:42:57.897 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 32 Mon Dec 10 11:42:58.045 Info: 802.1X changed + 33 Mon Dec 10 11:42:58.047 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 34 Mon Dec 10 11:42:58.047 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 35 Mon Dec 10 11:42:58.193 Info: 802.1X changed + 36 Mon Dec 10 11:42:58.195 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 37 Mon Dec 10 11:42:58.195 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 38 Mon Dec 10 11:42:58.342 Info: 802.1X changed + 39 Mon Dec 10 11:42:58.343 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 40 Mon Dec 10 11:42:58.344 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 41 Mon Dec 10 11:42:58.491 Info: 802.1X changed + 42 Mon Dec 10 11:42:58.493 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 43 Mon Dec 10 11:42:58.494 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 44 Mon Dec 10 11:42:58.640 Info: 802.1X changed + 45 Mon Dec 10 11:42:58.642 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 46 Mon Dec 10 11:42:58.642 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 47 Mon Dec 10 11:42:58.805 Info: 802.1X changed + 48 Mon Dec 10 11:42:58.806 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 49 Mon Dec 10 11:42:58.806 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 50 Mon Dec 10 11:42:58.958 Info: 802.1X changed + 51 Mon Dec 10 11:42:58.959 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 52 Mon Dec 10 11:42:58.960 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 53 Mon Dec 10 11:42:59.155 Info: 802.1X changed + 54 Mon Dec 10 11:42:59.157 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 55 Mon Dec 10 11:42:59.159 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 56 Mon Dec 10 11:42:59.352 Info: 802.1X changed + 57 Mon Dec 10 11:42:59.354 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 58 Mon Dec 10 11:42:59.354 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 59 Mon Dec 10 11:42:59.372 Driver Event: _bsd_80211_event_callback: APPLE80211_M_ROAM_END (en0) + 60 Mon Dec 10 11:42:59.372 Info: Roaming ended on interface en0 + 61 Mon Dec 10 11:42:59.372 Driver Event: _bsd_80211_event_callback: RSN_HANDSHAKE_DONE (en0) + 62 Mon Dec 10 11:42:59.373 Info: -[CWXPCInterfaceContext setRoamInProgress:reason:]_block_invoke: roam status metric data: CWAWDMetricRoamStatus: status:0 security: 4 profile:5 origin:<34fcb9>(-69) target:<6cf37f>(-56) latency:6.083439s + 63 Mon Dec 10 11:42:59.373 Info: -[CWAWDManager submitMetric:]: submitting metric id 0x90046 + 64 Mon Dec 10 11:42:59.373 Info: RESUME AWDL for interface en0, reason=Roam token=2685 + 65 Mon Dec 10 11:42:59.373 Info: PRIORITY LOCK REMOVED [client=airportd, type=4, interface=en0, priority=5] + 66 Mon Dec 10 11:42:59.374 Info: -[CWXPCInterfaceContext __setAWDLOperatingMode:interface:error:]: attempting to set AWDL mode to 0 + 67 Mon Dec 10 11:43:01.072 SC: airportdProcessSystemConfigurationEvent: Processing 'State:/Network/Service/18E14EA7-4641-4104-B315-A9315814912A/DHCP' + 68 Mon Dec 10 11:43:01.072 SC: _processDHCPChanges: State:/Network/Service/18E14EA7-4641-4104-B315-A9315814912A/DHCP + 69 Mon Dec 10 11:43:01.072 SC: _processDHCPChanges: DHCP airport_changed = 1 + 70 Mon Dec 10 11:43:01.073 Info: -[CWXPCSubsystem internal_submitIPConfigLatencyMetric:leaseDuration:]: IPConfig Latency metric data: CWAWDMetricIPConfigLatencyData: DHCP latency: 29010 msecs, duration: 480 mins, security: 4 + 71 Mon Dec 10 11:43:01.073 Info: -[CWAWDManager submitMetric:]: submitting metric id 0x90007 + 72 Mon Dec 10 11:43:01.073 SC: _setDHCPMessage: dhcpInfoKey "State:/Network/Interface/en0/AirPort/DHCP Message" = (null) + 73 Mon Dec 10 11:43:10.369 Driver Event: _bsd_80211_event_callback: LINK_QUALITY (en0) + 74 Mon Dec 10 11:43:10.369 Info: _bsd_80211_event_callback: link quality: RSSI=-57 dBm TxRate=162 Mbps + 75 Mon Dec 10 11:43:10.369 Info: link quality changed + 76 Mon Dec 10 11:43:23.376 Driver Event: _bsd_80211_event_callback: LINK_QUALITY (en0) + 77 Mon Dec 10 11:43:23.377 Info: _bsd_80211_event_callback: link quality: RSSI=-58 dBm TxRate=243 Mbps + 78 Mon Dec 10 11:43:23.377 Info: link quality changed + 79 Mon Dec 10 11:43:28.380 Driver Event: _bsd_80211_event_callback: LINK_QUALITY (en0) + 80 Mon Dec 10 11:43:28.380 Info: _bsd_80211_event_callback: link quality: RSSI=-58 dBm TxRate=216 Mbps + 81 Mon Dec 10 11:43:28.380 Info: link quality changed + 82 Mon Dec 10 11:43:31.744 AutoJoin: BACKGROUND SCAN request on interface en0 with SSID list (null) + 83 Mon Dec 10 11:43:31.747 Scan: Cache-assisted scan request on channel 1 does not require a live scan + 84 Mon Dec 10 11:43:31.748 Scan: Cache-assisted scan request on channel 2 does not require a live scan + 85 Mon Dec 10 11:43:31.748 Scan: Cache-assisted scan request on channel 3 does not require a live scan + 86 Mon Dec 10 11:43:31.748 Scan: Cache-assisted scan request does not require a live scan + 87 Mon Dec 10 11:43:31.748 AutoJoin: Successful cache-assisted background scan request with channels {( + 88 Mon Dec 10 11:43:31.748 [channelNumber=1(2GHz), channelWidth={20MHz}, active], + 89 Mon Dec 10 11:43:31.748 [channelNumber=2(2GHz), channelWidth={20MHz}, active], + 90 Mon Dec 10 11:43:31.748 [channelNumber=3(2GHz), channelWidth={20MHz}, active] + + + + + + + +{last_modified_time} test.log Page 3 + + + 91 Mon Dec 10 11:52:32.715 AutoJoin: Successful cache-assisted scan request for locationd with channels {( + 92 Mon Dec 10 11:52:32.715 [channelNumber=7(2GHz), channelWidth={20MHz}, active], + 93 Mon Dec 10 11:52:32.715 [channelNumber=8(2GHz), channelWidth={20MHz}, active], + 94 Mon Dec 10 11:52:32.715 [channelNumber=9(2GHz), channelWidth={20MHz}, active], + 95 Mon Dec 10 11:52:32.715 [channelNumber=10(2GHz), channelWidth={20MHz}, active], + 96 Mon Dec 10 11:52:32.715 [channelNumber=11(2GHz), channelWidth={20MHz}, active], + 97 Mon Dec 10 11:52:32.715 [channelNumber=12(2GHz), channelWidth={20MHz}, active] + 98 Mon Dec 10 11:52:32.715 )} took 0.2636 seconds, returned 10 results + 99 Mon Dec 10 11:52:32.994 Driver Event: _bsd_80211_event_callback: SCAN_CACHE_UPDATED (en0) + 100 Mon Dec 10 11:52:32.997 Info: QUERY SCAN CACHE request received from pid 92 (locationd) + 101 Mon Dec 10 11:52:32.998 AutoJoin: Successful cache-assisted scan request for locationd with channels {( + 102 Mon Dec 10 11:52:32.998 [channelNumber=13(2GHz), channelWidth={20MHz}, active], + 103 Mon Dec 10 11:52:32.998 [channelNumber=36(5GHz), channelWidth={40MHz(+1)}, active], + 104 Mon Dec 10 11:52:32.998 [channelNumber=40(5GHz), channelWidth={40MHz(-1)}, active], + 105 Mon Dec 10 11:52:32.998 [channelNumber=44(5GHz), channelWidth={40MHz(+1)}, active], + 106 Mon Dec 10 11:52:32.998 [channelNumber=48(5GHz), channelWidth={40MHz(-1)}, active], + 107 Mon Dec 10 11:52:32.998 [channelNumber=149(5GHz), channelWidth={20MHz}, active] + 108 Mon Dec 10 11:52:32.998 )} took 0.2822 seconds, returned 14 results + 109 Mon Dec 10 11:52:33.405 Driver Event: _bsd_80211_event_callback: SCAN_CACHE_UPDATED (en0) + 110 Mon Dec 10 11:52:33.408 Info: QUERY SCAN CACHE request received from pid 92 (locationd) + 111 Mon Dec 10 11:52:33.409 AutoJoin: Successful cache-assisted scan request for locationd with channels {( + 112 Mon Dec 10 11:52:33.409 [channelNumber=153(5GHz), channelWidth={40MHz(-1)}, active], + 113 Mon Dec 10 11:52:33.409 [channelNumber=157(5GHz), channelWidth={20MHz}, active], + 114 Mon Dec 10 11:52:33.409 [channelNumber=161(5GHz), channelWidth={40MHz(-1)}, active], + 115 Mon Dec 10 11:52:33.409 [channelNumber=165(5GHz), channelWidth={20MHz}, active], + 116 Mon Dec 10 11:52:33.409 [channelNumber=52(5GHz), channelWidth={40MHz(+1)}, DFS], + 117 Mon Dec 10 11:52:33.409 [channelNumber=56(5GHz), channelWidth={40MHz(-1)}, DFS] + 118 Mon Dec 10 11:52:33.409 )} took 0.4099 seconds, returned 11 results + 119 Mon Dec 10 11:52:33.669 Driver Event: _bsd_80211_event_callback: SCAN_CACHE_UPDATED (en0) + 120 Mon Dec 10 11:52:33.672 Info: QUERY SCAN CACHE request received from pid 92 (locationd) + 121 Mon Dec 10 11:52:33.672 AutoJoin: Successful cache-assisted scan request for locationd with channels {( + 122 Mon Dec 10 11:52:33.672 [channelNumber=60(5GHz), channelWidth={40MHz(+1)}, DFS], + 123 Mon Dec 10 11:52:33.672 [channelNumber=64(5GHz), channelWidth={40MHz(-1)}, DFS] + 124 Mon Dec 10 11:52:33.672 )} took 0.2625 seconds, returned 8 results + 125 Mon Dec 10 11:52:33.673 Info: scan cache updated + 126 Mon Dec 10 11:52:33.693 Info: SCAN request received from pid 92 (locationd) with priority 2 + 127 Mon Dec 10 11:52:33.693 Scan: locationd requested a live scan less than 10 seconds after previous request (1.4991s) returning cached scan results + 128 Mon Dec 10 11:52:33.728 Info: SCAN request received from pid 92 (locationd) with priority 2 + 129 Mon Dec 10 11:52:33.728 Scan: locationd requested a live scan less than 10 seconds after previous request (1.5339s) returning cached scan results + 130 Mon Dec 10 11:55:47.609 Driver Discovery: _PMConnectionHandler: caps = CPU Net Disk + 131 Mon Dec 10 11:55:47.609 Driver Discovery: _PMConnectionHandler: Being put into maintenance wake mode while fully awake. + 132 Mon Dec 10 11:55:47.610 Info: psCallback: powerSource = AC Power + 133 Mon Dec 10 11:55:47.610 Info: psCallback: set powersave disabled on en0 + 134 Mon Dec 10 11:55:47.637 Info: RELINQUISH BT PAGING LOCK request received from pid 106 (bluetoothd) + 135 Mon Dec 10 11:55:47.637 Info: RELINQUISH BT PAGING LOCK request received from pid 106 (bluetoothd) + 136 Mon Dec 10 11:55:47.638 BTC: BT PAGING state already set to 0 + 137 Mon Dec 10 11:55:47.638 BTC: BT PAGING state already set to 0 + 138 Mon Dec 10 11:55:47.638 Info: BT PAGING LOCK RELINQUISHED after 0.0 seconds + 139 Mon Dec 10 11:55:47.638 Info: BT PAGING LOCK RELINQUISHED after 0.0 seconds + 140 Mon Dec 10 11:55:47.638 Info: BT PAGING LOCK RELINQUISHED, re-enabling deferred WiFi requests + 141 Mon Dec 10 11:55:47.638 Info: BT PAGING LOCK RELINQUISHED, re-enabling deferred WiFi requests + 142 Mon Dec 10 11:55:48.093 IPC: ADDED XPC CLIENT CONNECTION [loginwindow (pid=101, euid=1651299376, egid=604256670)] + 143 Mon Dec 10 11:55:48.093 Info: START MONITORING EVENT request received from pid 101 (loginwindow) + 144 Mon Dec 10 11:55:48.093 Info: START MONITORING EVENT request received from pid 101 (loginwindow) + 145 Mon Dec 10 11:55:48.094 Info: START MONITORING EVENT request received from pid 101 (loginwindow) + 146 Mon Dec 10 11:55:48.094 Info: START MONITORING EVENT request received from pid 101 (loginwindow) + 147 Mon Dec 10 11:55:48.094 Info: START MONITORING EVENT request received from pid 101 (loginwindow) + 148 Mon Dec 10 11:55:48.094 Info: START MONITORING EVENT request received from pid 101 (loginwindow) + 149 Mon Dec 10 11:55:48.094 Info: START MONITORING EVENT request received from pid 101 (loginwindow) + 150 Mon Dec 10 11:55:48.104 Info: STOP MONITORING EVENT request received from pid 101 (loginwindow) + 151 Mon Dec 10 11:55:48.104 Info: STOP MONITORING EVENT request received from pid 101 (loginwindow) + 152 Mon Dec 10 11:55:48.104 Info: STOP MONITORING EVENT request received from pid 101 (loginwindow) + 153 Mon Dec 10 11:55:48.104 Info: STOP MONITORING EVENT request received from pid 101 (loginwindow) + 154 Mon Dec 10 11:55:48.104 Info: STOP MONITORING EVENT request received from pid 101 (loginwindow) + 155 Mon Dec 10 11:55:48.104 Info: STOP MONITORING EVENT request received from pid 101 (loginwindow) + 156 Mon Dec 10 11:55:48.105 Info: STOP MONITORING EVENT request received from pid 101 (loginwindow) + 157 Mon Dec 10 11:56:07.629 Driver Discovery: _PMConnectionHandler: caps = + 158 Mon Dec 10 11:56:07.629 AutoJoin: BEST CONNECTED SCAN CANCELLED on interface en0 + 159 Mon Dec 10 11:56:07.629 AutoJoin: BACKGROUND SCAN CANCELLED on interface en0 + 160 Mon Dec 10 11:56:07.629 AutoJoin: Auto-join retry cancelled on interface en0 + 161 Mon Dec 10 11:56:07.629 Offload: _tcpKeepAliveActive: TCP keep-alive is active. + 162 Mon Dec 10 11:56:07.637 P2P: _changeInterfaceFlags: Marking p2p0 down + 163 Mon Dec 10 11:56:07.637 Info: SleepAcknowledgementCheckForHostAP: Checking sleep readiness for HostAP + 164 Mon Dec 10 11:56:07.637 SleepAcknowledgementCheck: Checking sleep readiness + 165 Mon Dec 10 11:56:07.637 SleepAcknowledgementCheck: Delaying sleep acknowledgement because of VifUp + 166 Mon Dec 10 11:56:07.638 _interfaceFlagsChanged: KEV_DL_SIFFLAGS received for p2p0 [flags=0xffff8802 (down)]. + 167 Mon Dec 10 11:56:07.638 _interfaceFlagsChanged: Flags changed for p2p0 (0xffff8843 -> 0xffff8802) (down). + 168 Mon Dec 10 11:56:07.638 P2P: _deviceInterfaceMarkedDown: p2p0 marked down + 169 Mon Dec 10 11:56:07.638 P2P: _removeTimeoutForActionAndParam: Attempting to remove 'Stop GO' action (param = 0x0) + 170 Mon Dec 10 11:56:07.638 P2P: _removeTimeoutForActionAndParam: Attempting to remove 'Scan' action (param = 0x0) + 171 Mon Dec 10 11:56:07.638 P2P: _p2pSupervisorEventRunLoopCallback: Mark down complete for p2p0 + 172 Mon Dec 10 11:56:07.638 SleepAcknowledgementCheck: Checking sleep readiness + 173 Mon Dec 10 11:56:07.638 WoW: SleepAcknowledgementCheck: Checking if auto-join is in progress before sleep acknowledgement + 174 Mon Dec 10 11:56:07.638 WoW: SleepAcknowledgementDelayForAutoJoinAttempt_block_invoke: AUTO-JOIN attempt complete for en0, re-checking sleep readiness + 175 Mon Dec 10 11:56:07.638 SleepAcknowledgementCheck: Checking sleep readiness + 176 Mon Dec 10 11:56:07.639 WoW: _wowEnabled: WoW is active on en0 + 177 Mon Dec 10 11:56:07.639 WoW: wowExchangeRequiredForNode: WoW exchange not required for en0 + 178 Mon Dec 10 11:56:07.639 _acknowledgeSleepEvent: Acknowledging sleep event + 179 Mon Dec 10 11:56:07.639 Info: PRIORITY LOCK ADDED [client=airportd, type=4, interface=(null), priority=7] + 180 Mon Dec 10 11:56:07.640 AutoJoin: Auto-join retry cancelled on interface en0 + + + + + diff --git a/tests/fixtures/pr/test_page_length1.log.expected b/tests/fixtures/pr/test_page_length1.log.expected new file mode 100644 index 000000000..7162fe499 --- /dev/null +++ b/tests/fixtures/pr/test_page_length1.log.expected @@ -0,0 +1,10 @@ + 1 ntation processAirPortStateChanges]: pppConnectionState 0 + 2 Mon Dec 10 11:42:56.558 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 3 Mon Dec 10 11:42:56.705 Info: 802.1X changed + 4 Mon Dec 10 11:42:56.706 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 5 Mon Dec 10 11:42:56.706 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 6 Mon Dec 10 11:42:57.003 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 7 Mon Dec 10 11:42:57.152 Info: 802.1X changed + 8 Mon Dec 10 11:42:57.154 Info: -[AirPortExtraImplementation processAirPortStateChanges]: pppConnectionState 0 + 9 Mon Dec 10 11:42:57.154 Info: -[AirPortExtraImplementation processAirPortStateChanges]: old state=4 bars, new state=4 bars + 10 Mon Dec 10 11:42:57.302 Info: 802.1X changed \ No newline at end of file diff --git a/tests/test_pr.rs b/tests/test_pr.rs index da0785839..6063e569b 100644 --- a/tests/test_pr.rs +++ b/tests/test_pr.rs @@ -182,7 +182,7 @@ fn test_with_number_option_with_custom_separator_char_and_width() { } #[test] -fn test_valid_page_ranges() { +fn test_with_valid_page_ranges() { let test_file_path = "test_num_page.log"; let mut scenario = new_ucmd!(); scenario @@ -211,11 +211,10 @@ fn test_valid_page_ranges() { .fails() .stderr_is("pr: invalid --pages argument '5:1'") .stdout_is(""); - } #[test] -fn test_page_range() { +fn test_with_page_range() { let test_file_path = "test.log"; let expected_test_file_path = "test_page_range_1.log.expected"; let expected_test_file_path1 = "test_page_range_2.log.expected"; @@ -233,4 +232,46 @@ fn test_page_range() { .stdout_is_templated_fixture(expected_test_file_path1, vec![ (&"{last_modified_time}".to_string(), &value), ]); -} \ No newline at end of file +} + +#[test] +fn test_with_no_header_trailer_option() { + let test_file_path = "test_one_page.log"; + let expected_test_file_path = "test_one_page_no_ht.log.expected"; + let mut scenario = new_ucmd!(); + scenario + .args(&["-t", test_file_path]) + .succeeds() + .stdout_is_fixture(expected_test_file_path); +} + +#[test] +fn test_with_page_length_option() { + let test_file_path = "test.log"; + let expected_test_file_path = "test_page_length.log.expected"; + let expected_test_file_path1 = "test_page_length1.log.expected"; + let mut scenario = new_ucmd!(); + let value = file_last_modified_time(&scenario, test_file_path); + scenario + .args(&["--pages=2:3", "-l", "100", "-n", test_file_path]) + .succeeds() + .stdout_is_templated_fixture(expected_test_file_path, vec![ + (&"{last_modified_time}".to_string(), &value), + ]); + + new_ucmd!() + .args(&["--pages=2:3", "-l", "5", "-n", test_file_path]) + .succeeds() + .stdout_is_fixture(expected_test_file_path1); +} + +#[test] +fn test_with_suppress_error_option() { + let test_file_path = "test_num_page.log"; + let mut scenario = new_ucmd!(); + scenario + .args(&["--pages=20:5", "-r", test_file_path]) + .fails() + .stderr_is("") + .stdout_is(""); +}