本站源代码
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

42 líneas
998B

  1. // Copyright 2017 The Gitea Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. // +build race
  5. package git
  6. import (
  7. "context"
  8. "testing"
  9. "time"
  10. )
  11. func TestRunInDirTimeoutPipelineNoTimeout(t *testing.T) {
  12. maxLoops := 1000
  13. // 'git --version' does not block so it must be finished before the timeout triggered.
  14. cmd := NewCommand("--version")
  15. for i := 0; i < maxLoops; i++ {
  16. if err := cmd.RunInDirTimeoutPipeline(-1, "", nil, nil); err != nil {
  17. t.Fatal(err)
  18. }
  19. }
  20. }
  21. func TestRunInDirTimeoutPipelineAlwaysTimeout(t *testing.T) {
  22. maxLoops := 1000
  23. // 'git hash-object --stdin' blocks on stdin so we can have the timeout triggered.
  24. cmd := NewCommand("hash-object --stdin")
  25. for i := 0; i < maxLoops; i++ {
  26. if err := cmd.RunInDirTimeoutPipeline(1*time.Microsecond, "", nil, nil); err != nil {
  27. if err != context.DeadlineExceeded {
  28. t.Fatalf("Testing %d/%d: %v", i, maxLoops, err)
  29. }
  30. }
  31. }
  32. }
上海开阖软件有限公司 沪ICP备12045867号-1