Browse Source

Remove old tests

default_compile_flags
vector-of-bool 5 years ago
parent
commit
d64b24b9d3
11 changed files with 43 additions and 167 deletions
  1. +0
    -1
      tests/app_only.test/library.dds
  2. +0
    -2
      tests/app_only.test/package.dds
  3. +0
    -1
      tests/app_only.test/src/something.main.cpp
  4. +0
    -1
      tests/simple.test/library.dds
  5. +0
    -2
      tests/simple.test/package.dds
  6. +0
    -1
      tests/simple.test/src/foo.cpp
  7. +0
    -1
      tests/test_only.test/library.dds
  8. +0
    -2
      tests/test_only.test/package.dds
  9. +0
    -1
      tests/test_only.test/src/foo.test.cpp
  10. +43
    -0
      tools/self-test.py
  11. +0
    -155
      tools/test.py

+ 0
- 1
tests/app_only.test/library.dds View File

@@ -1 +0,0 @@
Name: app_only

+ 0
- 2
tests/app_only.test/package.dds View File

@@ -1,2 +0,0 @@
Name: dds-app_only-test
Version: 0.0.0

+ 0
- 1
tests/app_only.test/src/something.main.cpp View File

@@ -1 +0,0 @@
int main() { return 0; }

+ 0
- 1
tests/simple.test/library.dds View File

@@ -1 +0,0 @@
Name: simple

+ 0
- 2
tests/simple.test/package.dds View File

@@ -1,2 +0,0 @@
Name: dds-simple-test
Version: 0.0.0

+ 0
- 1
tests/simple.test/src/foo.cpp View File

@@ -1 +0,0 @@
int foo() { return 42; }

+ 0
- 1
tests/test_only.test/library.dds View File

@@ -1 +0,0 @@
Name: test_only

+ 0
- 2
tests/test_only.test/package.dds View File

@@ -1,2 +0,0 @@
Name: dds-test_only-test
Version: 0.0.0

+ 0
- 1
tests/test_only.test/src/foo.test.cpp View File

@@ -1 +0,0 @@
int main() { return 0; }

+ 43
- 0
tools/self-test.py View File

@@ -0,0 +1,43 @@
#!/usr/bin/env python3
import argparse
from pathlib import Path
from typing import List, NamedTuple
import shutil
import subprocess
import sys

ROOT = Path(__file__).parent.parent.absolute()


def bootstrap_self(exe: Path, toolchain: str):
# Copy the exe to another location, as windows refuses to let a binary be
# replaced while it is executing
new_exe = ROOT / '_dds.bootstrap-test.exe'
shutil.copy2(exe, new_exe)
res = subprocess.run([str(new_exe), 'build', f'-FT{toolchain}'])
new_exe.unlink()
if res.returncode != 0:
raise RuntimeError('The bootstrap test failed!')
print('Bootstrap test PASSED!')


def main(argv: List[str]) -> int:
parser = argparse.ArgumentParser()
parser.add_argument(
'--exe',
'-e',
help='Path to the dds executable to test',
required=True)
parser.add_argument(
'--toolchain',
'-T',
help='The dds toolchain to use while testing',
required=True,
)
args = parser.parse_args(argv)
bootstrap_self(Path(args.exe), args.toolchain)
return 0


if __name__ == "__main__":
sys.exit(main(sys.argv[1:]))

+ 0
- 155
tools/test.py View File

@@ -1,155 +0,0 @@
#!/usr/bin/env python3
import argparse
from pathlib import Path
from typing import List, NamedTuple
import shutil
import subprocess
import sys

ROOT = Path(__file__).parent.parent.absolute()


class TestOptions(NamedTuple):
exe: Path
toolchain: str


def run_test_dir(dir: Path, opts: TestOptions) -> bool:
fails = 0
fails += _run_subproc_test(
dir,
opts,
'Full Build',
'build',
'--full',
f'--toolchain={opts.toolchain}',
)
fails += _run_subproc_test(
dir,
opts,
'Source Distribution',
'sdist',
'create',
f'--out=_build/{dir.stem}/test.dsd',
'--replace',
)
return fails == 0


def _run_subproc_test(dir: Path, opts: TestOptions, name: str,
*args: str) -> int:
print(f'Running test: {dir.stem} - {name} ', end='')
out_dir = dir / '_build'
if out_dir.exists():
shutil.rmtree(out_dir)
res = subprocess.run(
[
str(opts.exe),
] + list(str(s) for s in args),
cwd=dir,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
)
if res.returncode != 0:
print('- FAILED')
print(f'Test failed with exit code '
f'[{res.returncode}]:\n{res.stdout.decode()}')
return 1
print('- PASSED')
return 0


def _run_build_test(dir: Path, opts: TestOptions) -> int:
print(f'Running test: {dir.stem} - build', end='')
out_dir = dir / '_build'
if out_dir.exists():
shutil.rmtree(out_dir)
res = subprocess.run(
[
str(opts.exe),
'build',
'--export',
'--warnings',
'--tests',
'--full',
f'--toolchain={opts.toolchain}',
f'--out={out_dir}',
f'--export-name={dir.stem}',
],
cwd=dir,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
)
if res.returncode != 0:
print('- FAILED')
print(f'Test failed with exit code '
f'[{res.returncode}]:\n{res.stdout.decode()}')
return 1
print('- PASSED')
return 0


def run_tests(opts: TestOptions) -> int:
print('Sanity check...')
subprocess.check_output([str(opts.exe), '--help'])
tests_subdir = ROOT / 'tests'

test_dirs = tests_subdir.glob('*.test')
ret = 0
for td in test_dirs:
if not run_test_dir(td, opts):
ret = 1
return ret


def bootstrap_self(opts: TestOptions):
# Copy the exe to another location, as windows refuses to let a binary be
# replaced while it is executing
new_exe = ROOT / '_dds.bootstrap-test.exe'
shutil.copy2(opts.exe, new_exe)
res = subprocess.run([
str(new_exe),
'build',
f'-FT{opts.toolchain}',
])
new_exe.unlink()
if res.returncode != 0:
print('The bootstrap test failed!', file=sys.stderr)
return False
print('Bootstrap test PASSED!')
return True


def main(argv: List[str]) -> int:
parser = argparse.ArgumentParser()
parser.add_argument(
'--exe',
'-e',
help='Path to the dds executable to test',
required=True)
parser.add_argument(
'--toolchain',
'-T',
help='The dds toolchain to use while testing',
required=True,
)
parser.add_argument(
'--skip-bootstrap-test',
action='store_true',
help='Skip the self-bootstrap test',
)
args = parser.parse_args(argv)

tc = args.toolchain
if not tc.startswith(':'):
tc = Path(tc).absolute()
opts = TestOptions(exe=Path(args.exe).absolute(), toolchain=tc)

if not args.skip_bootstrap_test and not bootstrap_self(opts):
return 2

return run_tests(opts)


if __name__ == "__main__":
sys.exit(main(sys.argv[1:]))

Loading…
Cancel
Save