mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-11-04 01:34:27 +00:00 
			
		
		
		
	Fix race in integration testlogger (#6556)
* Fix race in logger * At testing end drop the reference to the last test.
This commit is contained in:
		@@ -81,6 +81,8 @@ func TestMain(m *testing.M) {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
	exitCode := m.Run()
 | 
						exitCode := m.Run()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						writerCloser.t = nil
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if err = os.RemoveAll(setting.Indexer.IssuePath); err != nil {
 | 
						if err = os.RemoveAll(setting.Indexer.IssuePath); err != nil {
 | 
				
			||||||
		fmt.Printf("os.RemoveAll: %v\n", err)
 | 
							fmt.Printf("os.RemoveAll: %v\n", err)
 | 
				
			||||||
		os.Exit(1)
 | 
							os.Exit(1)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -33,6 +33,27 @@ func (w *testLoggerWriterCloser) Write(p []byte) (int, error) {
 | 
				
			|||||||
		if len(p) > 0 && p[len(p)-1] == '\n' {
 | 
							if len(p) > 0 && p[len(p)-1] == '\n' {
 | 
				
			||||||
			p = p[:len(p)-1]
 | 
								p = p[:len(p)-1]
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							defer func() {
 | 
				
			||||||
 | 
								err := recover()
 | 
				
			||||||
 | 
								if err == nil {
 | 
				
			||||||
 | 
									return
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								var errString string
 | 
				
			||||||
 | 
								errErr, ok := err.(error)
 | 
				
			||||||
 | 
								if ok {
 | 
				
			||||||
 | 
									errString = errErr.Error()
 | 
				
			||||||
 | 
								} else {
 | 
				
			||||||
 | 
									errString, ok = err.(string)
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								if !ok {
 | 
				
			||||||
 | 
									panic(err)
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								if !strings.HasPrefix(errString, "Log in goroutine after ") {
 | 
				
			||||||
 | 
									panic(err)
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		w.t.Log(string(p))
 | 
							w.t.Log(string(p))
 | 
				
			||||||
		return len(p), nil
 | 
							return len(p), nil
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user