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
57
58
59
60
61
62
63
64
65
66
67
68
69
//! The zip family's Apple flavour against its reference, `/usr/bin/zip`
//! (Apple's Zip 3.0, macOS and the BSDs). The rows shared by both flavours
//! are in `compat_zip_common.rs`; this suite holds the matrices and the
//! cases only Apple's build has.
//!
//! Task 5 (0.19.0): which names zip would operate on, `-sf` over every shape
//! of operand, directory, link, pattern and date filter
//! ([`zip_scan_matrix`]), and what Apple's build alone does with names.
#[cfg(unix)]
mod compat_harness;
#[cfg(unix)]
mod unix {
use super::compat_harness::*;
/// This suite is Apple's: other platforms' reference is Ubuntu's.
fn apple_here() -> bool {
if platform_zip_flavour() != "apple" {
eprintln!("skipped: this platform's zip reference is not Apple's");
return false;
}
true
}
/// Task 5: the scanning matrix, exit code, both streams and the tree.
#[test]
fn the_scan_matrix_matches_apples_zip() {
if !apple_here() {
return;
}
let cases = zip_scan_matrix("apple");
assert!(cases.len() >= 150, "{} cases", cases.len());
run_group(
"zip scan (apple)",
&cases,
Skipped::none(),
&assert_same_zip,
);
}
/// A newline in a name is shown raw (Ubuntu shows `^J`).
#[test]
fn a_newline_in_a_name_is_shown_as_it_is() {
if !apple_here() {
return;
}
let tree = ZipTree::standard().file_at(b"new\nline", b"x", 0o644);
let mut c = zip_case("zip", &["-sf", "t.zip", "new\nline"], tree);
c.zip_flavour = Some("apple");
assert!(assert_same_zip(&c));
let ours = stuffr_zip(&c);
assert!(
String::from_utf8_lossy(&ours.stdout).contains(" new\nline\n"),
"{}",
String::from_utf8_lossy(&ours.stdout)
);
}
/// Task 7: a signal during an update or a new archive, as the reference
/// answers it (the record's signal table; Review Focus 4).
#[test]
fn interrupts_match_the_reference() {
if !apple_here() {
return;
}
zip_interrupts_match("apple");
}
}