mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 16:40:24 +08:00 
			
		
		
		
	Fix nondeterministic behavior (#9341)
The underlying implementation of os.exec uses channels and goroutines. It is possible to have time-variant error values returned from Cmd.Wait depending on which comes first. Also, the git subcommand and options should be separated tokens. Fixes a flaky test in modules/git/command_test.go
This commit is contained in:
		@@ -30,7 +30,7 @@ func TestRunInDirTimeoutPipelineAlwaysTimeout(t *testing.T) {
 | 
			
		||||
	maxLoops := 1000
 | 
			
		||||
 | 
			
		||||
	// 'git hash-object --stdin' blocks on stdin so we can have the timeout triggered.
 | 
			
		||||
	cmd := NewCommand("hash-object --stdin")
 | 
			
		||||
	cmd := NewCommand("hash-object", "--stdin")
 | 
			
		||||
	for i := 0; i < maxLoops; i++ {
 | 
			
		||||
		if err := cmd.RunInDirTimeoutPipeline(1*time.Microsecond, "", nil, nil); err != nil {
 | 
			
		||||
			if err != context.DeadlineExceeded {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user