Merge branch 'fix-windows-tests' · GitoxideLabs/gitoxide@c2753b8 (original) (raw)

`@@ -17,7 +17,7 @@ mod from_tree {

`

17

17

`#[test]

`

18

18

`fn basic_usage_internal() -> gix_testtools::Result {

`

19

19

`basic_usage(gix_archive::Format::InternalTransientNonPersistable, |buf| {

`

20

``

`-

assert_eq!(buf.len(), if cfg!(windows) { 565 } else { 551 });

`

``

20

`+

assert_eq!(buf.len(), 551);

`

21

21

``

22

22

`let mut stream = gix_worktree_stream::Stream::from_read(std::io::Cursor::new(buf));

`

23

23

`let mut paths_and_modes = Vec::new();

`

`@@ -27,11 +27,7 @@ mod from_tree {

`

27

27

` entry.read_to_end(&mut buf).expect("stream can always be read");

`

28

28

`}

`

29

29

``

30

``

`-

let expected_link_mode = if cfg!(windows) {

`

31

``

`-

EntryKind::Blob

`

32

``

`-

} else {

`

33

``

`-

EntryKind::Link

`

34

``

`-

};

`

``

30

`+

let expected_link_mode = EntryKind::Link;

`

35

31

`let expected_exe_mode = if cfg!(windows) {

`

36

32

`EntryKind::Blob

`

37

33

`} else {

`

`@@ -53,11 +49,7 @@ mod from_tree {

`

53

49

`(

`

54

50

`"symlink-to-a".into(),

`

55

51

` expected_link_mode,

`

56

``

`-

hex_to_id(if cfg!(windows) {

`

57

``

`-

"45b983be36b73c0788dc9cbcb76cbb80fc7bb057"

`

58

``

`-

} else {

`

59

``

`-

"2e65efe2a145dda7ee51d1741299f848e5bf752e"

`

60

``

`-

})

`

``

52

`+

hex_to_id("2e65efe2a145dda7ee51d1741299f848e5bf752e")

`

61

53

`),

`

62

54

`(

`

63

55

`"dir/b".into(),

`

`@@ -119,34 +111,20 @@ mod from_tree {

`

119

111

` header.mode()?,

`

120

112

`));

`

121

113

`}

`

122

``

`-

let expected_symlink_type = if cfg!(windows) {

`

123

``

`-

EntryType::Regular

`

124

``

`-

} else {

`

125

``

`-

EntryType::Symlink

`

126

``

`-

};

`

``

114

`+

let expected_symlink_type = EntryType::Symlink;

`

127

115

`let expected_exe_mode = if cfg!(windows) { 420 } else { 493 };

`

128

116

`assert_eq!(

`

129

117

` out,

`

130

118

`[

`

131

119

`("prefix/.gitattributes", EntryType::Regular, 56, 420),

`

132

120

`("prefix/a", EntryType::Regular, 3, 420),

`

133

``

`-

(

`

134

``

`-

"prefix/symlink-to-a",

`

135

``

`-

expected_symlink_type,

`

136

``

`-

if cfg!(windows) { 3 } else { 0 },

`

137

``

`-

420

`

138

``

`-

),

`

``

121

`+

("prefix/symlink-to-a", expected_symlink_type, 0, 420),

`

139

122

`("prefix/dir/b", EntryType::Regular, 3, 420),

`

140

123

`("prefix/dir/subdir/exe", EntryType::Regular, 0, expected_exe_mode),

`

141

124

`("prefix/extra-file", EntryType::Regular, 21, 420),

`

142

125

`("prefix/extra-exe", EntryType::Regular, 0, expected_exe_mode),

`

143

126

`("prefix/extra-dir-empty", EntryType::Directory, 0, 420),

`

144

``

`-

(

`

145

``

`-

"prefix/extra-dir/symlink-to-extra",

`

146

``

`-

expected_symlink_type,

`

147

``

`-

if cfg!(windows) { 21 } else { 0 },

`

148

``

`-

420

`

149

``

`-

)

`

``

127

`+

("prefix/extra-dir/symlink-to-extra", expected_symlink_type, 0, 420)

`

150

128

`]

`

151

129

`.into_iter()

`

152

130

`.map(|(path, b, c, d)| (bstr::BStr::new(path).to_owned(), b, c, d))

`

`@@ -183,7 +161,7 @@ mod from_tree {

`

183

161

`},

`

184

162

` |buf| {

`

185

163

`assert!(

`

186

``

`-

buf.len() < 1270,

`

``

164

`+

buf.len() < 1280,

`

187

165

`"much bigger than uncompressed for some reason (565): {} < 1270",

`

188

166

` buf.len()

`

189

167

`);

`

`@@ -208,19 +186,11 @@ mod from_tree {

`

208

186

`);

`

209

187

`let mut link = ar.by_name("prefix/symlink-to-a")?;

`

210

188

`assert!(!link.is_dir());

`

211

``

`-

assert_eq!(

`

212

``

`-

link.is_symlink(),

`

213

``

`-

cfg!(not(windows)),

`

214

``

`-

"symlinks are supported as well, but only on Unix"

`

215

``

`-

);

`

216

``

`-

assert_eq!(

`

217

``

`-

link.unix_mode(),

`

218

``

`-

Some(if cfg!(windows) { 0o100644 } else { 0o120644 }),

`

219

``

`-

"the mode specifies what it should be"

`

220

``

`-

);

`

``

189

`+

assert!(link.is_symlink(), "symlinks are supported as well, but only on Unix");

`

``

190

`+

assert_eq!(link.unix_mode(), Some(0o120644), "the mode specifies what it should be");

`

221

191

`let mut buf = Vec::new();

`

222

192

` link.read_to_end(&mut buf)?;

`

223

``

`-

assert_eq!(buf.as_bstr(), if cfg!(windows) { "hi\n" } else { "a" });

`

``

193

`+

assert_eq!(buf.as_bstr(), "a");

`

224

194

`Ok(())

`

225

195

`},

`

226

196

`)

`