mirror of
https://github.com/ralsina/tartrazine.git
synced 2025-05-24 16:21:14 -03:00
test: fix platform-depenent paths in tests
Test Plan: - go test ./internal/code-generator/... -run Test_GeneratorTestSuite -testify.m TestGenerationFiles
This commit is contained in:
parent
e32a70a784
commit
1ab8148c10
@ -39,7 +39,7 @@ func (s *EnryTestSuite) TestRegexpEdgeCases() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, r := range regexpEdgeCases {
|
for _, r := range regexpEdgeCases {
|
||||||
filename := fmt.Sprintf("%s/samples/%s/%s", s.tmpLinguist, r.lang, r.filename)
|
filename := filepath.Join(s.tmpLinguist, "samples", r.lang, r.filename)
|
||||||
|
|
||||||
content, err := ioutil.ReadFile(filename)
|
content, err := ioutil.ReadFile(filename)
|
||||||
require.NoError(s.T(), err)
|
require.NoError(s.T(), err)
|
||||||
@ -116,7 +116,7 @@ func (s *EnryTestSuite) TestGetLanguage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *EnryTestSuite) TestGetLanguagesByModelineLinguist() {
|
func (s *EnryTestSuite) TestGetLanguagesByModelineLinguist() {
|
||||||
var modelinesDir = filepath.Join(s.tmpLinguist, "test/fixtures/Data/Modelines")
|
var modelinesDir = filepath.Join(s.tmpLinguist, "test", "fixtures", "Data", "Modelines")
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
|
@ -13,77 +13,77 @@ import (
|
|||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
var (
|
||||||
linguistURL = "https://github.com/github/linguist.git"
|
linguistURL = "https://github.com/github/linguist.git"
|
||||||
linguistClonedEnvVar = "ENRY_TEST_REPO"
|
linguistClonedEnvVar = "ENRY_TEST_REPO"
|
||||||
commit = "3a1bd3c3d3e741a8aaec4704f782e06f5cd2a00d"
|
commit = "3a1bd3c3d3e741a8aaec4704f782e06f5cd2a00d"
|
||||||
samplesDir = "samples"
|
samplesDir = "samples"
|
||||||
languagesFile = "lib/linguist/languages.yml"
|
languagesFile = filepath.Join("lib", "linguist", "languages.yml")
|
||||||
|
|
||||||
testDir = "test_files"
|
testDir = "test_files"
|
||||||
assetsDir = "../assets"
|
assetsDir = filepath.Join("..", "assets")
|
||||||
|
|
||||||
// Extensions test
|
// Extensions test
|
||||||
extensionGold = testDir + "/extension.gold"
|
extensionGold = filepath.Join(testDir, "extension.gold")
|
||||||
extensionTestTmplPath = assetsDir + "/extension.go.tmpl"
|
extensionTestTmplPath = filepath.Join(assetsDir, "extension.go.tmpl")
|
||||||
extensionTestTmplName = "extension.go.tmpl"
|
extensionTestTmplName = "extension.go.tmpl"
|
||||||
|
|
||||||
// Heuristics test
|
// Heuristics test
|
||||||
heuristicsTestFile = "lib/linguist/heuristics.yml"
|
heuristicsTestFile = filepath.Join("lib", "linguist", "heuristics.yml")
|
||||||
contentGold = testDir + "/content.gold"
|
contentGold = filepath.Join(testDir, "content.gold")
|
||||||
contentTestTmplPath = assetsDir + "/content.go.tmpl"
|
contentTestTmplPath = filepath.Join(assetsDir, "content.go.tmpl")
|
||||||
contentTestTmplName = "content.go.tmpl"
|
contentTestTmplName = "content.go.tmpl"
|
||||||
|
|
||||||
// Vendor test
|
// Vendor test
|
||||||
vendorTestFile = "lib/linguist/vendor.yml"
|
vendorTestFile = filepath.Join("lib", "linguist", "vendor.yml")
|
||||||
vendorGold = testDir + "/vendor.gold"
|
vendorGold = filepath.Join(testDir, "vendor.gold")
|
||||||
vendorTestTmplPath = assetsDir + "/vendor.go.tmpl"
|
vendorTestTmplPath = filepath.Join(assetsDir, "vendor.go.tmpl")
|
||||||
vendorTestTmplName = "vendor.go.tmpl"
|
vendorTestTmplName = "vendor.go.tmpl"
|
||||||
|
|
||||||
// Documentation test
|
// Documentation test
|
||||||
documentationTestFile = "lib/linguist/documentation.yml"
|
documentationTestFile = filepath.Join("lib", "linguist", "documentation.yml")
|
||||||
documentationGold = testDir + "/documentation.gold"
|
documentationGold = filepath.Join(testDir, "documentation.gold")
|
||||||
documentationTestTmplPath = assetsDir + "/documentation.go.tmpl"
|
documentationTestTmplPath = filepath.Join(assetsDir, "documentation.go.tmpl")
|
||||||
documentationTestTmplName = "documentation.go.tmpl"
|
documentationTestTmplName = "documentation.go.tmpl"
|
||||||
|
|
||||||
// Types test
|
// Types test
|
||||||
typeGold = testDir + "/type.gold"
|
typeGold = filepath.Join(testDir, "type.gold")
|
||||||
typeTestTmplPath = assetsDir + "/type.go.tmpl"
|
typeTestTmplPath = filepath.Join(assetsDir, "type.go.tmpl")
|
||||||
typeTestTmplName = "type.go.tmpl"
|
typeTestTmplName = "type.go.tmpl"
|
||||||
|
|
||||||
// Interpreters test
|
// Interpreters test
|
||||||
interpreterGold = testDir + "/interpreter.gold"
|
interpreterGold = filepath.Join(testDir, "interpreter.gold")
|
||||||
interpreterTestTmplPath = assetsDir + "/interpreter.go.tmpl"
|
interpreterTestTmplPath = filepath.Join(assetsDir, "interpreter.go.tmpl")
|
||||||
interpreterTestTmplName = "interpreter.go.tmpl"
|
interpreterTestTmplName = "interpreter.go.tmpl"
|
||||||
|
|
||||||
// Filenames test
|
// Filenames test
|
||||||
filenameGold = testDir + "/filename.gold"
|
filenameGold = filepath.Join(testDir, "filename.gold")
|
||||||
filenameTestTmplPath = assetsDir + "/filename.go.tmpl"
|
filenameTestTmplPath = filepath.Join(assetsDir, "filename.go.tmpl")
|
||||||
filenameTestTmplName = "filename.go.tmpl"
|
filenameTestTmplName = "filename.go.tmpl"
|
||||||
|
|
||||||
// Aliases test
|
// Aliases test
|
||||||
aliasGold = testDir + "/alias.gold"
|
aliasGold = filepath.Join(testDir, "alias.gold")
|
||||||
aliasTestTmplPath = assetsDir + "/alias.go.tmpl"
|
aliasTestTmplPath = filepath.Join(assetsDir, "alias.go.tmpl")
|
||||||
aliasTestTmplName = "alias.go.tmpl"
|
aliasTestTmplName = "alias.go.tmpl"
|
||||||
|
|
||||||
// Frequencies test
|
// Frequencies test
|
||||||
frequenciesGold = testDir + "/frequencies.gold"
|
frequenciesGold = filepath.Join(testDir, "frequencies.gold")
|
||||||
frequenciesTestTmplPath = assetsDir + "/frequencies.go.tmpl"
|
frequenciesTestTmplPath = filepath.Join(assetsDir, "frequencies.go.tmpl")
|
||||||
frequenciesTestTmplName = "frequencies.go.tmpl"
|
frequenciesTestTmplName = "frequencies.go.tmpl"
|
||||||
|
|
||||||
// commit test
|
// commit test
|
||||||
commitGold = testDir + "/commit.gold"
|
commitGold = filepath.Join(testDir, "commit.gold")
|
||||||
commitTestTmplPath = assetsDir + "/commit.go.tmpl"
|
commitTestTmplPath = filepath.Join(assetsDir, "commit.go.tmpl")
|
||||||
commitTestTmplName = "commit.go.tmpl"
|
commitTestTmplName = "commit.go.tmpl"
|
||||||
|
|
||||||
// mime test
|
// mime test
|
||||||
mimeTypeGold = testDir + "/mimeType.gold"
|
mimeTypeGold = filepath.Join(testDir, "mimeType.gold")
|
||||||
mimeTypeTestTmplPath = assetsDir + "/mimeType.go.tmpl"
|
mimeTypeTestTmplPath = filepath.Join(assetsDir, "mimeType.go.tmpl")
|
||||||
mimeTypeTestTmplName = "mimeType.go.tmpl"
|
mimeTypeTestTmplName = "mimeType.go.tmpl"
|
||||||
|
|
||||||
// colors test
|
// colors test
|
||||||
colorsGold = testDir + "/colors.gold"
|
colorsGold = filepath.Join(testDir, "colors.gold")
|
||||||
colorsTestTmplPath = assetsDir + "/colors.go.tmpl"
|
colorsTestTmplPath = filepath.Join(assetsDir, "colors.go.tmpl")
|
||||||
colorsTestTmplName = "colors.go.tmpl"
|
colorsTestTmplName = "colors.go.tmpl"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -291,7 +291,7 @@ func (s *GeneratorTestSuite) TestGenerationFiles() {
|
|||||||
gold, err := ioutil.ReadFile(test.wantOut)
|
gold, err := ioutil.ReadFile(test.wantOut)
|
||||||
assert.NoError(s.T(), err)
|
assert.NoError(s.T(), err)
|
||||||
|
|
||||||
outPath, err := ioutil.TempFile("/tmp", "generator-test-")
|
outPath, err := ioutil.TempFile("", "generator-test-")
|
||||||
assert.NoError(s.T(), err)
|
assert.NoError(s.T(), err)
|
||||||
defer os.Remove(outPath.Name())
|
defer os.Remove(outPath.Name())
|
||||||
err = test.generate(test.fileToParse, test.samplesDir, outPath.Name(), test.tmplPath, test.tmplName, test.commit)
|
err = test.generate(test.fileToParse, test.samplesDir, outPath.Name(), test.tmplPath, test.tmplName, test.commit)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user