Skip to content

Commit

Permalink
Add build option combination test script
Browse files Browse the repository at this point in the history
  • Loading branch information
TollyH committed May 13, 2024
1 parent 496dd96 commit 6c34dc8
Show file tree
Hide file tree
Showing 2 changed files with 129 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,21 @@ jobs:
name: AssEmbly-${{ matrix.runtime-target }}
path: Publish/${{ matrix.runtime-target }}/
if-no-files-found: error

test-build-opts:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install tqdm
run: pip3 install tqdm
- name: Test Build Option Combinations
run: python3 Scripts/test_build_options.py
111 changes: 111 additions & 0 deletions Scripts/test_build_options.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
"""
This script tests each possible combination of AssEmbly compilation options
to ensure that none of them result in build errors.
"""
import itertools
import os
import subprocess
import sys

import tqdm

BUILD_ARGS = [
"dotnet", "build", "AssEmbly.csproj", "-c", "Release",
"-p:TreatWarningsAsErrors=true", "-warnaserror"
]

EXTENSION_SET_OPTIONS = [
"V1_CALL_STACK_COMPAT",
"EXTENSION_SET_SIGNED",
"EXTENSION_SET_FLOATING_POINT",
"EXTENSION_SET_EXTENDED_BASE",
"GZIP_COMPRESSION",
"EXTENSION_SET_EXTERNAL_ASM",
"EXTENSION_SET_HEAP_ALLOCATE",
"EXTENSION_SET_FILE_SYSTEM",
"EXTENSION_SET_TERMINAL",
]

OPERATION_OPTIONS: dict[str, set[str]] = {
"ASSEMBLER": set(),
"ASSEMBLER_WARNINGS": {"ASSEMBLER"},
"PROCESSOR": set(),
"DEBUGGER": {"ASSEMBLER", "PROCESSOR", "DISASSEMBLER", "CLI"},
"DISASSEMBLER": set(),
"CLI": set(),
}

ALL_EXTENSION_SETS = ';' + ';'.join(EXTENSION_SET_OPTIONS) + ';'
ALL_OPERATIONS = ';' + ';'.join(OPERATION_OPTIONS) + ';'

# Change directory to AssEmbly repository root
os.chdir(os.path.dirname(os.path.dirname(__file__)))

print("Testing extension set combinations...")

combinations: list[tuple[str, ...]] = []
for length in range(len(EXTENSION_SET_OPTIONS) + 1):
for combination in itertools.combinations(EXTENSION_SET_OPTIONS, length):
combinations.append(combination)

failed_extension_set_combinations: list[str] = []
for combination in tqdm.tqdm(combinations):
combination_str = ';'.join(combination)
build_process = subprocess.Popen(
BUILD_ARGS
+ [f"-p:DefineConstants=\"{ALL_OPERATIONS}{combination_str};\""],
stdout=subprocess.DEVNULL
)
if build_process.wait() != 0:
failed_extension_set_combinations.append(combination_str)

print("Testing operation combinations...")

combinations: list[tuple[str, ...]] = []
for length in range(len(OPERATION_OPTIONS) + 1):
for combination in itertools.combinations(OPERATION_OPTIONS, length):
valid = True
for operation in combination:
# Skip combinations of operations where one or more operations
# are missing any of their required operations.
if not OPERATION_OPTIONS[operation].issubset(combination):
valid = False
break
if valid:
combinations.append(combination)

failed_operation_combinations: list[str] = []
for combination in tqdm.tqdm(combinations):
combination_str = ';'.join(combination)
build_process = subprocess.Popen(
BUILD_ARGS
+ [f"-p:DefineConstants=\"{ALL_EXTENSION_SETS}{combination_str};\""],
stdout=subprocess.DEVNULL
)
if build_process.wait() != 0:
failed_operation_combinations.append(combination_str)

# Output results
exit_code = 0

print()

if len(failed_extension_set_combinations) > 0:
exit_code += 1
print("Failed extension set combinations:")
for combination_str in failed_extension_set_combinations:
print(f" {combination_str}")
else:
print("All extension set combinations passed")

print()

if len(failed_operation_combinations) > 0:
exit_code += 1
print("Failed operation combinations:")
for combination_str in failed_operation_combinations:
print(f" {combination_str}")
else:
print("All operation combinations passed")

sys.exit(exit_code)

0 comments on commit 6c34dc8

Please sign in to comment.