MCPcopy
hub / github.com/syncthing/syncthing / TestNormalizationDarwinCaseFS

Function TestNormalizationDarwinCaseFS

lib/scanner/walk_test.go:280–334  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

278}
279
280func TestNormalizationDarwinCaseFS(t *testing.T) {
281 // This tests that normalization works on Darwin, through a CaseFS.
282
283 if !build.IsDarwin {
284 t.Skip("Normalization test not possible on non-Darwin")
285 return
286 }
287
288 testFs := newTestFs(new(fs.OptionDetectCaseConflicts))
289
290 testFs.RemoveAll("normalization")
291 defer testFs.RemoveAll("normalization")
292 testFs.MkdirAll("normalization", 0o755)
293
294 const (
295 inNFC = "\xC3\x84"
296 inNFD = "\x41\xCC\x88"
297 )
298
299 // Create dir in NFC
300 if err := testFs.Mkdir(filepath.Join("normalization", "dir-"+inNFC), 0o755); err != nil {
301 t.Fatal(err)
302 }
303
304 // Create file in NFC
305 fd, err := testFs.Create(filepath.Join("normalization", "dir-"+inNFC, "file-"+inNFC))
306 if err != nil {
307 t.Fatal(err)
308 }
309 fd.Close()
310
311 // Walk, which should normalize and return
312 walkDir(testFs, "normalization", nil, nil, 0)
313 tmp := walkDir(testFs, "normalization", nil, nil, 0)
314 if len(tmp) != 3 {
315 t.Error("Expected one file and one dir scanned")
316 }
317
318 // Verify we see the normalized entries in the result
319 foundFile := false
320 foundDir := false
321 for _, f := range tmp {
322 if f.Name == filepath.Join("normalization", "dir-"+inNFD) {
323 foundDir = true
324 continue
325 }
326 if f.Name == filepath.Join("normalization", "dir-"+inNFD, "file-"+inNFD) {
327 foundFile = true
328 continue
329 }
330 }
331 if !foundFile || !foundDir {
332 t.Error("Didn't find expected normalization form")
333 }
334}
335
336func TestIssue1507(_ *testing.T) {
337 w := &walker{}

Callers

nothing calls this directly

Calls 9

newTestFsFunction · 0.85
walkDirFunction · 0.85
FatalMethod · 0.80
RemoveAllMethod · 0.65
MkdirAllMethod · 0.65
MkdirMethod · 0.65
CreateMethod · 0.65
CloseMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected