Browse Source

Separate default toolchainsfor testing

default_compile_flags
vector-of-bool 4 years ago
parent
commit
b4e15a0a54
8 changed files with 34 additions and 7 deletions
  1. +5
    -0
      tests/gcc-9.tc.jsonc
  2. +4
    -0
      tests/msvc.tc.jsonc
  3. +4
    -1
      tests/test_basics.py
  4. +1
    -0
      tests/test_compile_deps.py
  5. +2
    -2
      tools/dds_ci/dds.py
  6. +2
    -2
      tools/dds_ci/main.py
  7. +2
    -0
      tools/dds_ci/paths.py
  8. +14
    -2
      tools/dds_ci/toolchain.py

+ 5
- 0
tests/gcc-9.tc.jsonc View File

@@ -0,0 +1,5 @@
{
"compiler_id": 'gnu',
"cxx_version": 'c++17',
"cxx_compiler": 'g++-9',
}

+ 4
- 0
tests/msvc.tc.jsonc View File

@@ -0,0 +1,4 @@
{
"compiler_id": 'msvc',
"cxx_version": "c++17"
}

+ 4
- 1
tests/test_basics.py View File

@@ -1,5 +1,7 @@
import pytest
from subprocess import CalledProcessError
import time

import pytest

from dds_ci import paths
from dds_ci.testing import Project, PackageJSON
@@ -29,6 +31,7 @@ def test_build_simple(tmp_project: Project) -> None:
tmp_project.write('src/f.cpp', r'void f() {}')
tmp_project.build()
# Writing again will build again:
time.sleep(0.2) # Sleep long enough to register a file change
tmp_project.write('src/f.cpp', r'bad again')
with pytest.raises(CalledProcessError):
tmp_project.build()

+ 1
- 0
tests/test_compile_deps.py View File

@@ -79,6 +79,7 @@ def test_partial_build_rebuild(test_project: Project) -> None:
with pytest.raises(subprocess.CalledProcessError):
test_project.build()

# Pause long enough for timestamps to change
test_project.write('src/2.cpp', '''
#include "./values.hpp"


+ 2
- 2
tools/dds_ci/dds.py View File

@@ -86,7 +86,7 @@ class DDSWrapper:
:param build_root: The root directory where the output will be written.
:param jobs: The number of jobs to use. Default is CPU-count + 2
"""
toolchain = toolchain or tc_mod.get_default_test_toolchain()
toolchain = toolchain or tc_mod.get_default_audit_toolchain()
jobs = jobs or multiprocessing.cpu_count() + 2
self.run([
'build',
@@ -99,7 +99,7 @@ class DDSWrapper:
])

def build_deps(self, args: proc.CommandLine, *, toolchain: Optional[Path] = None) -> None:
toolchain = toolchain or tc_mod.get_default_test_toolchain()
toolchain = toolchain or tc_mod.get_default_audit_toolchain()
self.run([
'build-deps',
f'--toolchain={toolchain}',

+ 2
- 2
tools/dds_ci/main.py View File

@@ -78,7 +78,7 @@ def test_build(dds: DDSWrapper, args: CommandArguments) -> DDSWrapper:
Execute the build that generates the test-mode executable. Uses the given 'dds'
to build the new dds. Returns a DDSWrapper around the generated test executable.
"""
test_tc = args.test_toolchain or toolchain.get_default_test_toolchain()
test_tc = args.test_toolchain or toolchain.get_default_audit_toolchain()
build_dir = paths.BUILD_DIR
with toolchain.fixup_toolchain(test_tc) as new_tc:
dds.build(toolchain=new_tc, root=paths.PROJECT_ROOT, build_root=build_dir, jobs=args.jobs)
@@ -110,7 +110,7 @@ def main_build(dds: DDSWrapper, args: CommandArguments) -> int:
"""
main_tc = args.toolchain or (
# If we are in rapid-dev mode, use the test toolchain, which had audit/debug enabled
toolchain.get_default_toolchain() if not args.rapid else toolchain.get_default_test_toolchain())
toolchain.get_default_toolchain() if not args.rapid else toolchain.get_default_audit_toolchain())
with toolchain.fixup_toolchain(main_tc) as new_tc:
try:
dds.build(toolchain=new_tc, root=paths.PROJECT_ROOT, build_root=paths.BUILD_DIR, jobs=args.jobs)

+ 2
- 0
tools/dds_ci/paths.py View File

@@ -10,6 +10,8 @@ from typing import Iterator, Optional
PROJECT_ROOT = Path(__file__).absolute().parent.parent.parent
#: The <repo>/tools directory
TOOLS_DIR = PROJECT_ROOT / 'tools'
#: The <repo>/tests directory
TESTS_DIR = PROJECT_ROOT / 'tests'
#: The default build directory
BUILD_DIR = PROJECT_ROOT / '_build'
#: The directory were w prebuild/bootstrapped results will go, and scratch space for the build

+ 14
- 2
tools/dds_ci/toolchain.py View File

@@ -36,7 +36,7 @@ def fixup_toolchain(json_file: Pathish) -> Iterator[Path]:
yield new_json


def get_default_test_toolchain() -> Path:
def get_default_audit_toolchain() -> Path:
"""
Get the default toolchain that should be used for dev and test based on the
host platform.
@@ -47,13 +47,25 @@ def get_default_test_toolchain() -> Path:
return paths.TOOLS_DIR / 'gcc-9-test.jsonc'
if sys.platform == 'win32':
return paths.TOOLS_DIR / 'msvc-audit.jsonc'
if sys.platform in 'linux':
if sys.platform == 'linux':
return paths.TOOLS_DIR / 'gcc-9-audit.jsonc'
if sys.platform == 'darwin':
return paths.TOOLS_DIR / 'gcc-9-audit-macos.jsonc'
raise RuntimeError(f'Unable to determine the default toolchain (sys.platform is {sys.platform!r})')


def get_default_test_toolchain() -> Path:
"""
Get the default toolchain that should be used by tests that need a toolchain
to use for executing dds.
"""
if sys.platform == 'win32':
return paths.TESTS_DIR / 'msvc.tc.jsonc'
if sys.platform in ('linux', 'darwin'):
return paths.TESTS_DIR / 'gcc-9.tc.jsonc'
raise RuntimeError(f'Unable to determine the default toolchain (sys.platform is {sys.platform!r})')


def get_default_toolchain() -> Path:
"""
Get the default toolchain that should be used to generate the release executable

Loading…
Cancel
Save