From fbfe84f661837227d46c1ac1bfdb562d74811cd9 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 22 Feb 2026 15:46:00 +0000 Subject: [PATCH 1/2] Add -RunTests flag to execute quantlib-test-suite.exe after build - Add -RunTests parameter to Build-QuantLibDLL.ps1 (implies -BuildTests) - After build, locate the test exe and run it with the DLL directory on PATH - Validate exit code 0 and "*** No errors detected" in output - Enable tests by default in the workflow (both push/PR and workflow_dispatch) - Add run_tests input to workflow_dispatch for manual control https://claude.ai/code/session_01Pe2NhovoMN1DaU6vjJ1gjj --- .github/workflows/build.yml | 11 ++++++++-- scripts/Build-QuantLibDLL.ps1 | 40 ++++++++++++++++++++++++++++++++++- 2 files changed, 48 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3462b17..9e2c9bf 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -19,6 +19,10 @@ on: description: "Build and include QuantLib test suite" type: boolean default: true + run_tests: + description: "Run the QuantLib test suite after building" + type: boolean + default: true create_release: description: "Create a GitHub Release with the zip asset" type: boolean @@ -43,7 +47,10 @@ jobs: - name: Build QuantLib DLL shell: pwsh run: | - $buildTestsFlag = if ("${{ inputs.build_tests }}" -eq "true") { "-BuildTests" } else { "" } + $buildTests = "${{ inputs.build_tests }}" -ne "false" + $runTests = "${{ inputs.run_tests }}" -ne "false" + $buildTestsFlag = if ($buildTests) { "-BuildTests" } else { "" } + $runTestsFlag = if ($runTests) { "-RunTests" } else { "" } $cmd = "scripts/Build-QuantLibDLL.ps1" + " -QuantLibVersion $env:QL_VERSION" + " -BoostVersion $env:BOOST_VERSION" + @@ -51,7 +58,7 @@ jobs: " -TempDir ${{ runner.temp }}\quantlib-build" + " -PackageZip" + " -ZipOutputDir ${{ github.workspace }}" + - " $buildTestsFlag" + " $buildTestsFlag $runTestsFlag" Write-Host "Running: $cmd" Invoke-Expression $cmd diff --git a/scripts/Build-QuantLibDLL.ps1 b/scripts/Build-QuantLibDLL.ps1 index 77b9b79..4bcf258 100644 --- a/scripts/Build-QuantLibDLL.ps1 +++ b/scripts/Build-QuantLibDLL.ps1 @@ -38,6 +38,9 @@ .PARAMETER BuildTests Also build the QuantLib test suite. +.PARAMETER RunTests + Run the QuantLib test suite after building. Implies -BuildTests. + .PARAMETER PackageZip Create a distributable zip containing QuantLib DLL + headers + Boost headers. @@ -59,12 +62,16 @@ param( [string]$TempDir = (Join-Path (Split-Path $PSScriptRoot) "build"), [int]$Jobs = 0, [switch]$BuildTests, + [switch]$RunTests, [switch]$PackageZip, [string]$ZipOutputDir = "." ) $ErrorActionPreference = "Stop" +# -RunTests implies -BuildTests +if ($RunTests) { $BuildTests = [switch]::new($true) } + $BoostVersionU = $BoostVersion -replace '\.', '_' if ($Jobs -eq 0) { $Jobs = (Get-CimInstance Win32_Processor).NumberOfLogicalProcessors @@ -300,7 +307,38 @@ if (Test-Path "$InstallDir\bin") { } # ========================================================================== -# 6. Package zip (optional) +# 6. Run test suite (optional) +# ========================================================================== +if ($RunTests) { + Write-Host "==> Running QuantLib test suite" + $TestExePath = Get-ChildItem -Recurse "$QLBuildDir\test-suite" -Filter "quantlib-test-suite.exe" | + Where-Object { $_.Directory.Name -eq "Release" } | Select-Object -First 1 + if (-not $TestExePath) { + throw "quantlib-test-suite.exe not found under $QLBuildDir\test-suite" + } + Write-Host " Executable: $($TestExePath.FullName)" + + # Add the DLL directory to PATH so the test can find the QuantLib DLL + $DllDir = (Get-ChildItem -Recurse $QLBuildDir -Filter "QuantLib*.dll" | + Where-Object { $_.Directory.Name -eq "Release" } | Select-Object -First 1).DirectoryName + $env:PATH = "$DllDir;$env:PATH" + Write-Host " DLL directory added to PATH: $DllDir" + + $testOutput = & $TestExePath.FullName 2>&1 | Out-String + $testExitCode = $LASTEXITCODE + Write-Host $testOutput + + if ($testExitCode -ne 0) { + throw "quantlib-test-suite.exe exited with code $testExitCode (expected 0)" + } + if ($testOutput -notmatch '\*\*\* No errors detected') { + throw "Test suite output did not contain '*** No errors detected'" + } + Write-Host "==> Test suite PASSED (exit code 0, no errors detected)" +} + +# ========================================================================== +# 7. Package zip (optional) # ========================================================================== if ($PackageZip) { Write-Host "==> Packaging distribution zip" From 7ec32dfcac00c8b2a6e9a940e96aec7a3d5b6741 Mon Sep 17 00:00:00 2001 From: fumitoh Date: Mon, 23 Feb 2026 13:23:45 +0900 Subject: [PATCH 2/2] Fix PrimitivePolynomials export and build configuration (#9) * Fix PrimitivePolynomials export patch to match actual header format The primitivepolynomials.hpp declaration uses a multi-line extern "C" block, so "extern" and "const long *const PrimitivePolynomials" are on separate lines. The previous .Replace() looked for them as a contiguous string and silently failed to match. Match just "const long *const PrimitivePolynomials" instead, and guard with a QL_EXPORT check to prevent double application. https://claude.ai/code/session_01VaKuQu3KJqit4LpCz2ruzS * Fix benchmark install failure: use correct CMake option name QuantLib v1.41 does not have a QL_BUILD_BENCHMARK option (it was silently ignored). The correct option is QL_INSTALL_BENCHMARK, which controls whether cmake --install tries to install quantlib-benchmark.exe. Without this fix, the install step fails when BuildTests is enabled because the benchmark exe is never built (only ql_test_suite target is built) but the install rule still expects it. https://claude.ai/code/session_01VaKuQu3KJqit4LpCz2ruzS * Disable run_tests by default in CI workflow Change the run_tests input default from true to false and fix the logic so push/PR triggers (where the input is empty) also skip tests. Tests can still be run via workflow_dispatch by setting run_tests=true. https://claude.ai/code/session_01VaKuQu3KJqit4LpCz2ruzS --------- Co-authored-by: Claude --- .github/workflows/build.yml | 4 ++-- scripts/Build-QuantLibDLL.ps1 | 12 ++++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9e2c9bf..1822c11 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,7 +22,7 @@ on: run_tests: description: "Run the QuantLib test suite after building" type: boolean - default: true + default: false create_release: description: "Create a GitHub Release with the zip asset" type: boolean @@ -48,7 +48,7 @@ jobs: shell: pwsh run: | $buildTests = "${{ inputs.build_tests }}" -ne "false" - $runTests = "${{ inputs.run_tests }}" -ne "false" + $runTests = "${{ inputs.run_tests }}" -eq "true" $buildTestsFlag = if ($buildTests) { "-BuildTests" } else { "" } $runTestsFlag = if ($runTests) { "-RunTests" } else { "" } $cmd = "scripts/Build-QuantLibDLL.ps1" + diff --git a/scripts/Build-QuantLibDLL.ps1 b/scripts/Build-QuantLibDLL.ps1 index 4bcf258..c6247da 100644 --- a/scripts/Build-QuantLibDLL.ps1 +++ b/scripts/Build-QuantLibDLL.ps1 @@ -222,9 +222,13 @@ $ppContent = Get-Content $ppHeader -Raw if (-not $ppContent.Contains('qldefines.hpp')) { $ppContent = $ppContent -replace '(#define\s+primitivepolynomials_hpp)', "`$1`n`n#include " } -$ppContent = $ppContent.Replace( - 'extern const long *const PrimitivePolynomials', - 'extern QL_EXPORT const long *const PrimitivePolynomials') +if (-not $ppContent.Contains('QL_EXPORT')) { + # NOTE: The declaration uses multi-line "extern ... 'C' ... const long *const" + # so we must match just "const long *const PrimitivePolynomials" (not "extern const ..."). + $ppContent = $ppContent.Replace( + 'const long *const PrimitivePolynomials', + 'QL_EXPORT const long *const PrimitivePolynomials') +} [System.IO.File]::WriteAllText($ppHeader, $ppContent) # ========================================================================== @@ -243,7 +247,7 @@ $cmakeArgs = @( "-DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON" '-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded$<$:Debug>DLL' "-DBoost_INCLUDE_DIR=$BoostIncludeDir" - "-DQL_BUILD_BENCHMARK=OFF" + "-DQL_INSTALL_BENCHMARK=OFF" "-DQL_BUILD_EXAMPLES=OFF" "-DQL_BUILD_TEST_SUITE=$( if ($BuildTests) { 'ON' } else { 'OFF' } )" "-Wno-dev"