Implement builders to build Boost from source code

This commit is contained in:
Maxim Lobanov
2020-05-27 09:24:57 +03:00
parent 886c1d6104
commit 610555ac3d
36 changed files with 2005 additions and 0 deletions

15
tests/Common.Tests.ps1 Normal file
View File

@@ -0,0 +1,15 @@
Describe "Common Tests" {
$BOOST_HEADERS = Join-Path -Path ${env:BOOST_ROOT} -ChildPath "boost"
It "Check that symlinks points to existing files" {
Get-ChildItem $BOOST_HEADERS -File -Recurse | Where-Object { $_.Target } | ForEach-Object {
$_.Target | Should -Exist
}
}
It "Check if there is no invalid symlinks" {
Get-ChildItem $BOOST_HEADERS -Recurse -File | ForEach-Object {
Get-Content $_.FullName -Raw | Should -Not -BeNullOrEmpty
}
}
}

62
tests/Nix.Tests.ps1 Normal file
View File

@@ -0,0 +1,62 @@
param (
[Version] $Version,
[String] $Platform
)
Import-Module (Join-Path $PSScriptRoot "../helpers/pester-extensions.psm1")
Set-Location "sources"
$env:Path="$env:Path;${env:BOOST_ROOT}\lib"
if ($Platform -eq "linux-16.04") {
Write-Host "Install dependencies"
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 60 `
--slave /usr/bin/g++ g++ /usr/bin/g++-7
sudo update-alternatives --config gcc
}
Describe "Nix Tests" {
It "Simple code" {
"g++ -w -I ${env:BOOST_ROOT}/include main.cpp -o headers_test" | Should -ReturnZeroExitCode
"./headers_test" | Should -ReturnZeroExitCode
}
It "Test header existence" {
"g++ -w -std=c++14 -I ${env:BOOST_ROOT}/include main-headers.cpp -o headers_test_2" | Should -ReturnZeroExitCode
"./headers_test_2" | Should -ReturnZeroExitCode
}
It "Test shared debug" {
$BuildParams = (
"-w", "-DBOOST_LOG_DYN_LINK",
"-I", "${env:BOOST_ROOT}/include",
"-L", "${env:BOOST_ROOT}/lib", "main_log.cpp",
"-l:libboost_log_setup-mt-d-x64.so.${Version}",
"-l:libboost_log-mt-d-x64.so.${Version}",
"-l:libboost_thread-mt-d-x64.so.${Version}",
"-l:libboost_filesystem-mt-d-x64.so.${Version}",
"-lpthread"
)
"g++ $BuildParams -o test_shared_debug" | Should -ReturnZeroExitCode
"./test_shared_debug" | Should -ReturnZeroExitCode
}
It "Test shared release" {
$BuildParams = (
"-w", "-DBOOST_LOG_DYN_LINK",
"-I", "${env:BOOST_ROOT}/include",
"-L", "${env:BOOST_ROOT}/lib", "main_log.cpp",
"-l:libboost_log_setup-mt-x64.so.${Version}",
"-l:libboost_log-mt-x64.so.${Version}",
"-l:libboost_thread-mt-x64.so.${Version}",
"-l:libboost_filesystem-mt-x64.so.${Version}",
"-lpthread"
)
"g++ $BuildParams -o test_shared_release" | Should -ReturnZeroExitCode
"./test_shared_release" | Should -ReturnZeroExitCode
}
}

69
tests/Windows.Tests.ps1 Normal file
View File

@@ -0,0 +1,69 @@
param (
[Version] $Version,
[String] $Platform
)
Import-Module (Join-Path $PSScriptRoot "../helpers/pester-extensions.psm1")
Import-Module (Join-Path $PSScriptRoot "../helpers/win-vs-env.psm1")
Set-Location -Path "sources"
$env:Path="$env:Path;${env:BOOST_ROOT}\lib"
Write-Host "Initialize VS dev environment"
Invoke-VSDevEnvironment
Describe "Windows Tests" {
It "Run simple code" {
"cl -nologo /EHsc -I ${env:BOOST_ROOT}\include main.cpp" | Should -ReturnZeroExitCode
".\main.exe" | Should -ReturnZeroExitCode
}
It "Build with static libraries 1" {
$buildArguments = @(
"/EHsc",
"/I", "${env:BOOST_ROOT}\include",
"main-headers.cpp",
"/link", "/LIBPATH:${env:BOOST_ROOT}\lib",
"/OUT:main_static_lib_1.exe"
)
"cl -nologo $buildArguments" | Should -ReturnZeroExitCode
".\main_static_lib_1.exe" | Should -ReturnZeroExitCode
}
It "Build with dynamic libraries 1" {
$buildArguments = @(
"/EHsc", "/MD",
"/I", "${env:BOOST_ROOT}\include",
"main-headers.cpp",
"/link", "/LIBPATH:${env:BOOST_ROOT}\lib",
"/OUT:main_dynamic_lib_1.exe"
)
"cl -nologo $buildArguments" | Should -ReturnZeroExitCode
".\main_dynamic_lib_1.exe" | Should -ReturnZeroExitCode
}
It "Build with static libraries 2" {
$buildArguments = @(
"/EHsc",
"/I", "${env:BOOST_ROOT}\include",
"main_log.cpp",
"/link", "/LIBPATH:${env:BOOST_ROOT}\lib",
"/OUT:main_static_lib_2.exe"
)
"cl -nologo $buildArguments" | Should -ReturnZeroExitCode
".\main_static_lib_2.exe" | Should -ReturnZeroExitCode
}
It "Build with dynamic libraries 2" {
$buildArguments = @(
"/EHsc", "/MD",
"/I", "${env:BOOST_ROOT}\include",
"main_log.cpp",
"/link", "/LIBPATH:${env:BOOST_ROOT}\lib",
"/OUT:main_dynamic_lib_2.exe"
)
"cl -nologo $buildArguments" | Should -ReturnZeroExitCode
".\main_dynamic_lib_2.exe" | Should -ReturnZeroExitCode
}
}

View File

@@ -0,0 +1,22 @@
#include <cassert>
#include <exception>
#include <iostream>
#include <cstdint>
#include <boost/safe_numerics/safe_integer.hpp>
int main()
{
std::cout << "Using safe numerics" << std::endl;
try{
using namespace boost::safe_numerics;
safe<int> x = INT_MAX - 5;
++x;
}
catch(const std::exception & e){
std::cout << e.what() << std::endl;
std::cout << "error detected!" << std::endl;
}
return 0;
}

13
tests/sources/main.cpp Normal file
View File

@@ -0,0 +1,13 @@
#include <boost/algorithm/string.hpp>
#include <string>
#include <iostream>
using namespace boost::algorithm;
int main()
{
std::string s = "Boost C++ Libraries";
std::cout << to_upper_copy(s) << '\n';
return 0;
}

View File

@@ -0,0 +1,13 @@
#include <boost/log/trivial.hpp>
int main(int, char*[])
{
BOOST_LOG_TRIVIAL(trace) << "A trace severity message";
BOOST_LOG_TRIVIAL(debug) << "A debug severity message";
BOOST_LOG_TRIVIAL(info) << "An informational severity message";
BOOST_LOG_TRIVIAL(warning) << "A warning severity message";
BOOST_LOG_TRIVIAL(error) << "An error severity message";
BOOST_LOG_TRIVIAL(fatal) << "A fatal severity message";
return 0;
}