Skip to content

suite.Require deadlock  #1520

@vitalyisaev2

Description

@vitalyisaev2

If require object hasn't been initialized before calling suite.Require method, it will be created on the base of *testing.T returned from suite.T() (code):

// Require returns a require context for suite.
func (suite *Suite) Require() *require.Assertions {
	suite.mu.Lock()
	defer suite.mu.Unlock()
	if suite.require == nil {
		suite.require = require.New(suite.T())
	}
	return suite.require
}

This will result in a deadlock because suite.T() wants to acquire the lock that has been already acquired:

// T retrieves the current *testing.T context.
func (suite *Suite) T() *testing.T {
	suite.mu.RLock()
	defer suite.mu.RUnlock()
	return suite.t
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugpkg-suiteChange related to package testify/suite

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions