A fork of Gitea (see branch `mj`) adding Majority Judgment Polls 𐄷 over Issues and Merge Requests. https://git.mieuxvoter.fr
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
1001 B

  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. }