forked from rosa/hakurei
internal/rosa/python: run tests via helper
Despite the lack of standards, pytest seems somewhat widely agreed upon. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
@@ -22,7 +22,7 @@ func (t Toolchain) newMeson() (pkg.Artifact, string) {
|
||||
},
|
||||
}, &PipHelper{
|
||||
EnterSource: true,
|
||||
Script: `
|
||||
Check: `
|
||||
cd 'test cases'
|
||||
rm -rf \
|
||||
'common/32 has header' \
|
||||
|
||||
@@ -117,14 +117,23 @@ type PipHelper struct {
|
||||
EnterSource bool
|
||||
// Whether to install to build environment after install.
|
||||
Install bool
|
||||
// Whether to skip running tests.
|
||||
SkipCheck bool
|
||||
// Replaces pytest if non-empty.
|
||||
Check string
|
||||
// Runs after install.
|
||||
Script string
|
||||
}
|
||||
|
||||
var _ Helper = new(PipHelper)
|
||||
|
||||
// extra returns python.
|
||||
func (*PipHelper) extra(int) P { return P{Python} }
|
||||
// extra returns python, or pytest if defaults are assumed.
|
||||
func (attr *PipHelper) extra(int) P {
|
||||
if attr == nil || (!attr.SkipCheck && attr.Check == "") {
|
||||
return P{PythonPyTest}
|
||||
}
|
||||
return P{Python}
|
||||
}
|
||||
|
||||
// wantsChmod returns true.
|
||||
func (*PipHelper) wantsChmod() bool { return true }
|
||||
@@ -154,18 +163,27 @@ func (attr *PipHelper) script(name string) string {
|
||||
--no-build-isolation \`
|
||||
}
|
||||
|
||||
script := attr.Script
|
||||
var script string
|
||||
if attr.Install {
|
||||
script = `pip3 install \
|
||||
script += `pip3 install \
|
||||
--no-index \
|
||||
--prefix=/system \
|
||||
--no-build-isolation \
|
||||
'` + sourcePath.String() + `'
|
||||
` + script
|
||||
`
|
||||
}
|
||||
if attr.EnterSource {
|
||||
script = "cd '/usr/src/" + name + "'\n" + script
|
||||
script += "cd '/usr/src/" + name + "'\n"
|
||||
}
|
||||
if !attr.SkipCheck {
|
||||
if attr.Check == "" {
|
||||
// some test suites fall apart when ran out-of-tree
|
||||
script += "(cd '" + sourcePath.String() + "' && pytest)\n"
|
||||
} else {
|
||||
script += attr.Check
|
||||
}
|
||||
}
|
||||
script += attr.Script
|
||||
|
||||
return `
|
||||
pip3 install \
|
||||
@@ -263,7 +281,10 @@ func init() {
|
||||
"pypa/setuptools",
|
||||
"v"+version, checksum,
|
||||
), nil, &PipHelper{
|
||||
// error: invalid command 'dist_info'
|
||||
BuildIsolation: true,
|
||||
// pytest circular dependency
|
||||
SkipCheck: true,
|
||||
}, nil)
|
||||
}
|
||||
|
||||
@@ -284,7 +305,10 @@ func init() {
|
||||
"SETUPTOOLS_SCM_PRETEND_VERSION=" + version,
|
||||
},
|
||||
}, &PipHelper{
|
||||
// upstream is monorepo of two packages (setuptools-scm)
|
||||
Append: []string{"vcs-versioning"},
|
||||
// pytest circular dependency
|
||||
SkipCheck: true,
|
||||
}, nil,
|
||||
PythonSetuptools,
|
||||
PythonPackaging,
|
||||
@@ -308,7 +332,10 @@ func init() {
|
||||
"SETUPTOOLS_SCM_PRETEND_VERSION=" + version,
|
||||
},
|
||||
}, &PipHelper{
|
||||
// upstream is monorepo of two packages
|
||||
Append: []string{"setuptools-scm"},
|
||||
// pytest circular dependency
|
||||
SkipCheck: true,
|
||||
}, nil,
|
||||
PythonSetuptools,
|
||||
PythonVCSVersioning,
|
||||
@@ -328,7 +355,10 @@ func init() {
|
||||
"pypa/flit",
|
||||
version, checksum,
|
||||
), nil, &PipHelper{
|
||||
// upstream has other unused packages with many dependencies
|
||||
Append: []string{"flit_core"},
|
||||
// pytest circular dependency
|
||||
SkipCheck: true,
|
||||
}, nil,
|
||||
)
|
||||
}
|
||||
@@ -345,7 +375,10 @@ func init() {
|
||||
version, newFromGitHub(
|
||||
"pypa/packaging",
|
||||
version, checksum,
|
||||
), nil, nil, P{PythonFlitCore},
|
||||
), nil, &PipHelper{
|
||||
// pytest circular dependency
|
||||
SkipCheck: true,
|
||||
}, P{PythonFlitCore},
|
||||
)
|
||||
}
|
||||
|
||||
@@ -361,7 +394,10 @@ func init() {
|
||||
version, newFromGitHub(
|
||||
"cpburnz/python-pathspec",
|
||||
"v"+version, checksum,
|
||||
), nil, nil, P{PythonFlitCore},
|
||||
), nil, &PipHelper{
|
||||
// pytest circular dependency
|
||||
SkipCheck: true,
|
||||
}, P{PythonFlitCore},
|
||||
)
|
||||
}
|
||||
|
||||
@@ -377,7 +413,10 @@ func init() {
|
||||
version, newFromGitHub(
|
||||
"pypa/trove-classifiers",
|
||||
version, checksum,
|
||||
), nil, nil, P{PythonSetuptools},
|
||||
), nil, &PipHelper{
|
||||
// pytest circular dependency
|
||||
SkipCheck: true,
|
||||
}, P{PythonSetuptools},
|
||||
)
|
||||
}
|
||||
|
||||
@@ -397,7 +436,10 @@ func init() {
|
||||
Env: []string{
|
||||
"SETUPTOOLS_SCM_PRETEND_VERSION_FOR_PLUGGY=" + version,
|
||||
},
|
||||
}, nil, P{PythonSetuptoolsSCM},
|
||||
}, &PipHelper{
|
||||
// pytest circular dependency
|
||||
SkipCheck: true,
|
||||
}, P{PythonSetuptoolsSCM},
|
||||
)
|
||||
}
|
||||
|
||||
@@ -414,7 +456,10 @@ func init() {
|
||||
"pypa/hatch",
|
||||
"hatch-v"+version, checksum,
|
||||
), nil, &PipHelper{
|
||||
// upstream has other unused packages with many dependencies
|
||||
Append: []string{"backend"},
|
||||
// pytest circular dependency
|
||||
SkipCheck: true,
|
||||
}, nil,
|
||||
PythonPackaging,
|
||||
PythonPathspec,
|
||||
@@ -435,7 +480,10 @@ func init() {
|
||||
version, newFromGitHub(
|
||||
"pygments/pygments",
|
||||
version, checksum,
|
||||
), nil, nil, P{PythonHatchling},
|
||||
), nil, &PipHelper{
|
||||
// pytest circular dependency
|
||||
SkipCheck: true,
|
||||
}, P{PythonHatchling},
|
||||
)
|
||||
}
|
||||
|
||||
@@ -455,7 +503,10 @@ func init() {
|
||||
Env: []string{
|
||||
"SETUPTOOLS_SCM_PRETEND_VERSION_FOR_INICONFIG=" + version,
|
||||
},
|
||||
}, nil, P{PythonSetuptoolsSCM},
|
||||
}, &PipHelper{
|
||||
// pytest circular dependency
|
||||
SkipCheck: true,
|
||||
}, P{PythonSetuptoolsSCM},
|
||||
)
|
||||
}
|
||||
|
||||
@@ -475,7 +526,10 @@ func init() {
|
||||
Env: []string{
|
||||
"SETUPTOOLS_SCM_PRETEND_VERSION_FOR_PYTEST=" + version,
|
||||
},
|
||||
}, nil, P{PythonSetuptoolsSCM},
|
||||
}, &PipHelper{
|
||||
// many dependencies
|
||||
SkipCheck: true,
|
||||
}, P{PythonSetuptoolsSCM},
|
||||
PythonIniConfig,
|
||||
PythonPackaging,
|
||||
PythonPluggy,
|
||||
@@ -496,13 +550,9 @@ func init() {
|
||||
"pallets/markupsafe",
|
||||
version, checksum,
|
||||
), nil, &PipHelper{
|
||||
EnterSource: true,
|
||||
// ModuleNotFoundError: No module named 'markupsafe'
|
||||
Install: true,
|
||||
Script: "pytest",
|
||||
}, P{
|
||||
PythonSetuptools,
|
||||
PythonPyTest,
|
||||
},
|
||||
}, P{PythonSetuptools},
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user