26 lines
930 B
Python
26 lines
930 B
Python
"""Run private Go tests in a temporary source copy; public files stay untouched."""
|
|
from pathlib import Path
|
|
import shutil
|
|
import subprocess
|
|
import sys
|
|
import tempfile
|
|
|
|
ROOT=Path(__file__).resolve().parents[1]
|
|
|
|
|
|
def main():
|
|
subprocess.run([sys.executable, '-X', 'utf8', str(ROOT/'student-tests/readiness_test.py')], cwd=ROOT, check=True)
|
|
with tempfile.TemporaryDirectory(prefix='lab4-student-') as folder:
|
|
target=Path(folder)
|
|
for path in ROOT.glob('*.go'):
|
|
shutil.copyfile(path,target/path.name)
|
|
for name in ('go.mod','go.sum'):
|
|
shutil.copyfile(ROOT/name,target/name)
|
|
shutil.copytree(ROOT/'migrations',target/'migrations')
|
|
shutil.copyfile(ROOT/'student-tests/validation_test.go',target/'validation_test.go')
|
|
subprocess.run(['go','test','-tags','studentvalidation','-count=1','-v','./...'],cwd=target,check=True)
|
|
|
|
|
|
if __name__=='__main__':
|
|
main()
|