TestBisync is a test engine for bisync test cases.
(ctx context.Context, t *testing.T, path1, path2 string)
| 316 | |
| 317 | // TestBisync is a test engine for bisync test cases. |
| 318 | func testBisync(ctx context.Context, t *testing.T, path1, path2 string) { |
| 319 | ci := fs.GetConfig(ctx) |
| 320 | ciSave := *ci |
| 321 | defer func() { |
| 322 | *ci = ciSave |
| 323 | }() |
| 324 | if *argRefreshTimes { |
| 325 | ci.RefreshTimes = true |
| 326 | } |
| 327 | bisync.ColorsLock.Lock() |
| 328 | bisync.Colors = true |
| 329 | bisync.ColorsLock.Unlock() |
| 330 | ci.FsCacheExpireDuration = fs.Duration(5 * time.Hour) |
| 331 | |
| 332 | baseDir, err := os.Getwd() |
| 333 | require.NoError(t, err, "get current directory") |
| 334 | randName := time.Now().Format("150405") + random.String(8) // some bucket backends don't like dots, keep this short to avoid linux errors |
| 335 | tempDir := filepath.Join(os.TempDir(), randName) |
| 336 | workDir := filepath.Join(tempDir, "workdir") |
| 337 | |
| 338 | b := &bisyncTest{ |
| 339 | // per-test state |
| 340 | t: t, |
| 341 | // global state |
| 342 | tempDir: tempDir, |
| 343 | randName: randName, |
| 344 | workDir: workDir, |
| 345 | dataRoot: filepath.Join(baseDir, "testdata"), |
| 346 | logDir: filepath.Join(tempDir, "logs"), |
| 347 | logPath: filepath.Join(workDir, logFileName), |
| 348 | // global flags |
| 349 | argRemote1: path1, |
| 350 | argRemote2: path2, |
| 351 | noCompare: *argNoCompare, |
| 352 | noCleanup: *argNoCleanup, |
| 353 | golden: *argGolden, |
| 354 | debug: *argDebug, |
| 355 | stopAt: *argStopAt, |
| 356 | } |
| 357 | |
| 358 | b.mkdir(b.tempDir) |
| 359 | b.mkdir(b.logDir) |
| 360 | |
| 361 | fnHandle := atexit.Register(func() { |
| 362 | if atexit.Signalled() { |
| 363 | b.cleanupAll() |
| 364 | } |
| 365 | }) |
| 366 | defer func() { |
| 367 | b.cleanupAll() |
| 368 | atexit.Unregister(fnHandle) |
| 369 | }() |
| 370 | |
| 371 | argCase := *argTestCase |
| 372 | if argCase == "" { |
| 373 | argCase = "all" |
| 374 | if testing.Short() { |
| 375 | // remote tests can be long, help with "go test -short" |
no test coverage detected
searching dependent graphs…