mirror of
https://github.com/ralsina/tartrazine.git
synced 2025-05-23 08:30:07 -03:00
Add the external test linguist dir from env var
This allows to use a cached directory with linguist instead of cloning and speeds up the tests by -10s on my local machine. Signed-off-by: Vadim Markovtsev <vadim@sourced.tech>
This commit is contained in:
parent
557cc51f55
commit
250519bb51
@ -20,6 +20,7 @@ type EnryTestSuite struct {
|
|||||||
suite.Suite
|
suite.Suite
|
||||||
repoLinguist string
|
repoLinguist string
|
||||||
samplesDir string
|
samplesDir string
|
||||||
|
cloned bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestEnryTestSuite(t *testing.T) {
|
func TestEnryTestSuite(t *testing.T) {
|
||||||
@ -28,14 +29,20 @@ func TestEnryTestSuite(t *testing.T) {
|
|||||||
|
|
||||||
func (s *EnryTestSuite) SetupSuite() {
|
func (s *EnryTestSuite) SetupSuite() {
|
||||||
var err error
|
var err error
|
||||||
s.repoLinguist, err = ioutil.TempDir("", "linguist-")
|
s.repoLinguist = os.Getenv("ENRY_TEST_REPO")
|
||||||
assert.NoError(s.T(), err)
|
s.cloned = len(s.repoLinguist) == 0
|
||||||
|
if s.cloned {
|
||||||
|
s.repoLinguist, err = ioutil.TempDir("", "linguist-")
|
||||||
|
assert.NoError(s.T(), err)
|
||||||
|
}
|
||||||
|
|
||||||
s.samplesDir = filepath.Join(s.repoLinguist, "samples")
|
s.samplesDir = filepath.Join(s.repoLinguist, "samples")
|
||||||
|
|
||||||
cmd := exec.Command("git", "clone", linguistURL, s.repoLinguist)
|
if s.cloned {
|
||||||
err = cmd.Run()
|
cmd := exec.Command("git", "clone", linguistURL, s.repoLinguist)
|
||||||
assert.NoError(s.T(), err)
|
err = cmd.Run()
|
||||||
|
assert.NoError(s.T(), err)
|
||||||
|
}
|
||||||
|
|
||||||
cwd, err := os.Getwd()
|
cwd, err := os.Getwd()
|
||||||
assert.NoError(s.T(), err)
|
assert.NoError(s.T(), err)
|
||||||
@ -43,7 +50,7 @@ func (s *EnryTestSuite) SetupSuite() {
|
|||||||
err = os.Chdir(s.repoLinguist)
|
err = os.Chdir(s.repoLinguist)
|
||||||
assert.NoError(s.T(), err)
|
assert.NoError(s.T(), err)
|
||||||
|
|
||||||
cmd = exec.Command("git", "checkout", data.LinguistCommit)
|
cmd := exec.Command("git", "checkout", data.LinguistCommit)
|
||||||
err = cmd.Run()
|
err = cmd.Run()
|
||||||
assert.NoError(s.T(), err)
|
assert.NoError(s.T(), err)
|
||||||
|
|
||||||
@ -52,8 +59,10 @@ func (s *EnryTestSuite) SetupSuite() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *EnryTestSuite) TearDownSuite() {
|
func (s *EnryTestSuite) TearDownSuite() {
|
||||||
err := os.RemoveAll(s.repoLinguist)
|
if s.cloned {
|
||||||
assert.NoError(s.T(), err)
|
err := os.RemoveAll(s.repoLinguist)
|
||||||
|
assert.NoError(s.T(), err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *EnryTestSuite) TestGetLanguage() {
|
func (s *EnryTestSuite) TestGetLanguage() {
|
||||||
|
@ -13,7 +13,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
lingustURL = "https://github.com/github/linguist.git"
|
linguistURL = "https://github.com/github/linguist.git"
|
||||||
commit = "d5c8db3fb91963c4b2762ca2ea2ff7cfac109f68"
|
commit = "d5c8db3fb91963c4b2762ca2ea2ff7cfac109f68"
|
||||||
samplesDir = "samples"
|
samplesDir = "samples"
|
||||||
languagesFile = "lib/linguist/languages.yml"
|
languagesFile = "lib/linguist/languages.yml"
|
||||||
@ -80,6 +80,7 @@ const (
|
|||||||
type GeneratorTestSuite struct {
|
type GeneratorTestSuite struct {
|
||||||
suite.Suite
|
suite.Suite
|
||||||
tmpLinguist string
|
tmpLinguist string
|
||||||
|
cloned bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGeneratorTestSuite(t *testing.T) {
|
func TestGeneratorTestSuite(t *testing.T) {
|
||||||
@ -88,12 +89,18 @@ func TestGeneratorTestSuite(t *testing.T) {
|
|||||||
|
|
||||||
func (s *GeneratorTestSuite) SetupSuite() {
|
func (s *GeneratorTestSuite) SetupSuite() {
|
||||||
var err error
|
var err error
|
||||||
s.tmpLinguist, err = ioutil.TempDir("", "linguist-")
|
s.tmpLinguist = os.Getenv("ENRY_TEST_REPO")
|
||||||
assert.NoError(s.T(), err)
|
s.cloned = len(s.tmpLinguist) == 0
|
||||||
|
if s.cloned {
|
||||||
|
s.tmpLinguist, err = ioutil.TempDir("", "linguist-")
|
||||||
|
assert.NoError(s.T(), err)
|
||||||
|
}
|
||||||
|
|
||||||
cmd := exec.Command("git", "clone", lingustURL, s.tmpLinguist)
|
if s.cloned {
|
||||||
err = cmd.Run()
|
cmd := exec.Command("git", "clone", linguistURL, s.tmpLinguist)
|
||||||
assert.NoError(s.T(), err)
|
err = cmd.Run()
|
||||||
|
assert.NoError(s.T(), err)
|
||||||
|
}
|
||||||
|
|
||||||
cwd, err := os.Getwd()
|
cwd, err := os.Getwd()
|
||||||
assert.NoError(s.T(), err)
|
assert.NoError(s.T(), err)
|
||||||
@ -101,7 +108,7 @@ func (s *GeneratorTestSuite) SetupSuite() {
|
|||||||
err = os.Chdir(s.tmpLinguist)
|
err = os.Chdir(s.tmpLinguist)
|
||||||
assert.NoError(s.T(), err)
|
assert.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)
|
assert.NoError(s.T(), err)
|
||||||
|
|
||||||
@ -110,8 +117,10 @@ func (s *GeneratorTestSuite) SetupSuite() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *GeneratorTestSuite) TearDownSuite() {
|
func (s *GeneratorTestSuite) TearDownSuite() {
|
||||||
err := os.RemoveAll(s.tmpLinguist)
|
if s.cloned {
|
||||||
assert.NoError(s.T(), err)
|
err := os.RemoveAll(s.tmpLinguist)
|
||||||
|
assert.NoError(s.T(), err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *GeneratorTestSuite) TestGenerationFiles() {
|
func (s *GeneratorTestSuite) TestGenerationFiles() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user