test: fail fast on suite setup/teardown

This commit is contained in:
Alex Bezzubov
2022-11-23 22:05:50 +01:00
parent 43475949cc
commit 6be1ebe9d6
2 changed files with 7 additions and 7 deletions

View File

@@ -78,7 +78,7 @@ func (s *enryBaseTestSuite) SetupSuite() {
func (s *enryBaseTestSuite) TearDownSuite() { func (s *enryBaseTestSuite) TearDownSuite() {
if s.isCleanupNeeded { if s.isCleanupNeeded {
err := os.RemoveAll(s.tmpLinguistDir) err := os.RemoveAll(s.tmpLinguistDir)
assert.NoError(s.T(), err) require.NoError(s.T(), err)
} }
} }

View File

@@ -125,28 +125,28 @@ func (s *GeneratorTestSuite) maybeCloneLinguist() {
isLinguistCloned := s.tmpLinguistDir != "" isLinguistCloned := s.tmpLinguistDir != ""
if !isLinguistCloned { if !isLinguistCloned {
s.tmpLinguistDir, err = ioutil.TempDir("", "linguist-") s.tmpLinguistDir, err = ioutil.TempDir("", "linguist-")
assert.NoError(s.T(), err) require.NoError(s.T(), err)
s.T().Logf("Cloning Linguist repo to '%s' as %s was not set\n", s.T().Logf("Cloning Linguist repo to '%s' as %s was not set\n",
s.tmpLinguistDir, linguistClonedEnvVar) s.tmpLinguistDir, linguistClonedEnvVar)
cmd := exec.Command("git", "clone", "--depth", "100", linguistURL, s.tmpLinguistDir) cmd := exec.Command("git", "clone", "--depth", "100", linguistURL, s.tmpLinguistDir)
err = cmd.Run() err = cmd.Run()
assert.NoError(s.T(), err) require.NoError(s.T(), err)
s.isCleanupNeeded = true s.isCleanupNeeded = true
} }
cwd, err := os.Getwd() cwd, err := os.Getwd()
assert.NoError(s.T(), err) require.NoError(s.T(), err)
err = os.Chdir(s.tmpLinguistDir) err = os.Chdir(s.tmpLinguistDir)
assert.NoError(s.T(), err) require.NoError(s.T(), err)
cmd := exec.Command("git", "checkout", commit) cmd := exec.Command("git", "checkout", commit)
err = cmd.Run() err = cmd.Run()
assert.NoError(s.T(), err) require.NoError(s.T(), err)
err = os.Chdir(cwd) err = os.Chdir(cwd)
assert.NoError(s.T(), err) require.NoError(s.T(), err)
} }
func (s *GeneratorTestSuite) SetupSuite() { func (s *GeneratorTestSuite) SetupSuite() {