diff options
| author | Leitwolf | 2026-10-24 20:29:24 +0300 |
|---|---|---|
| committer | GitHub | 2026-10-24 20:29:24 +0300 |
| commit | 13f81a480a93807c14dddb5abdb97355ced4d4c5 (patch) | |
| tree | cd2055cb2eeb0bdef1d5bed1d39d9569df6f5b97 /tools | |
| parent | 4f1c759cffcb14bd6511e1d7c5fbace682e24f2d (diff) | |
| parent | a2edf60b9f410d26485ac7c0492870a0905f9545 (diff) | |
| download | catch3-13f81a480a93807c14dddb5abdb97355ced4d4c5.tar.gz | |
Merge pull request #16 from Progmasoft/chore/remove-upstream-leftovers
Remove what Catch2's maintainers left that is not ours
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/misc/CMakeLists.txt | 8 | ||||
| -rw-r--r-- | tools/misc/appveyorBuildConfigurationScript.bat | 21 | ||||
| -rw-r--r-- | tools/misc/appveyorMergeCoverageScript.py | 9 | ||||
| -rw-r--r-- | tools/misc/appveyorTestRunScript.bat | 17 | ||||
| -rw-r--r-- | tools/misc/coverage-helper.cpp | 142 | ||||
| -rw-r--r-- | tools/misc/installOpenCppCoverage.ps1 | 19 | ||||
| -rwxr-xr-x | tools/scripts/developBuild.py | 9 | ||||
| -rw-r--r-- | tools/scripts/extractFeaturesFromReleaseNotes.py | 92 | ||||
| -rwxr-xr-x | tools/scripts/generateAmalgamatedFiles.py | 11 | ||||
| -rwxr-xr-x | tools/scripts/majorRelease.py | 9 | ||||
| -rwxr-xr-x | tools/scripts/minorRelease.py | 9 | ||||
| -rwxr-xr-x | tools/scripts/patchRelease.py | 9 | ||||
| -rw-r--r-- | tools/scripts/releaseCommon.py | 116 |
13 files changed, 11 insertions, 460 deletions
diff --git a/tools/misc/CMakeLists.txt b/tools/misc/CMakeLists.txt deleted file mode 100644 index 39e816a1..00000000 --- a/tools/misc/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -cmake_minimum_required(VERSION 3.16) -project(CatchCoverageHelper LANGUAGES CXX) - -add_executable(CoverageHelper coverage-helper.cpp) -target_compile_features(CoverageHelper PRIVATE cxx_std_11) -if(MSVC) - target_compile_options(CoverageHelper PRIVATE /W4 /w44265 /WX /w44061 /w44062) -endif() diff --git a/tools/misc/appveyorBuildConfigurationScript.bat b/tools/misc/appveyorBuildConfigurationScript.bat deleted file mode 100644 index 75b39550..00000000 --- a/tools/misc/appveyorBuildConfigurationScript.bat +++ /dev/null @@ -1,21 +0,0 @@ -SETLOCAL EnableDelayedExpansion - -@REM # Possibilities: -@REM # Debug build + coverage -@REM # Debug build + examples -@REM # Debug build + --- -@REM # Release build -if "%CONFIGURATION%"=="Debug" ( - if "%coverage%"=="1" ( - @REM # coverage needs to build the special helper as well as the main - cmake -Stools/misc -Bbuild-misc -A%PLATFORM% || exit /b !ERRORLEVEL! - cmake --build build-misc || exit /b !ERRORLEVEL! - cmake -S. -BBuild -A%PLATFORM% -DCATCH_TEST_USE_WMAIN=%wmain% -DMEMORYCHECK_COMMAND=build-misc\Debug\CoverageHelper.exe -DMEMORYCHECK_COMMAND_OPTIONS=--sep-- -DMEMORYCHECK_TYPE=Valgrind -DCATCH_BUILD_EXAMPLES=%examples% -DCATCH_BUILD_EXTRA_TESTS=%examples% -DCATCH_ENABLE_CONFIGURE_TESTS=%configure_tests% -DCATCH_DEVELOPMENT_BUILD=ON || exit /b !ERRORLEVEL! - ) else ( - @REM # We know that coverage is 0 - cmake -S. -BBuild -A%PLATFORM% -DCATCH_TEST_USE_WMAIN=%wmain% -DCATCH_BUILD_EXAMPLES=%examples% -DCATCH_BUILD_EXTRA_TESTS=%examples% -DCATCH_BUILD_SURROGATES=%surrogates% -DCATCH_DEVELOPMENT_BUILD=ON -DCATCH_ENABLE_CONFIGURE_TESTS=%configure_tests% || exit /b !ERRORLEVEL! - ) -) -if "%CONFIGURATION%"=="Release" ( - cmake -S. -BBuild -A%PLATFORM% -DCATCH_TEST_USE_WMAIN=%wmain% -DCATCH_DEVELOPMENT_BUILD=ON || exit /b !ERRORLEVEL! -) diff --git a/tools/misc/appveyorMergeCoverageScript.py b/tools/misc/appveyorMergeCoverageScript.py deleted file mode 100644 index 5b71f6e1..00000000 --- a/tools/misc/appveyorMergeCoverageScript.py +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env python3 - -import glob -import subprocess - -if __name__ == '__main__': - cov_files = list(glob.glob('tests/cov-report*.bin')) - base_cmd = ['OpenCppCoverage', '--quiet', '--export_type=cobertura:cobertura.xml'] + ['--input_coverage={}'.format(f) for f in cov_files] - subprocess.check_call(base_cmd) diff --git a/tools/misc/appveyorTestRunScript.bat b/tools/misc/appveyorTestRunScript.bat deleted file mode 100644 index 661bae24..00000000 --- a/tools/misc/appveyorTestRunScript.bat +++ /dev/null @@ -1,17 +0,0 @@ -SETLOCAL EnableDelayedExpansion - -rem Disable launching the JIT debugger for ctest.exe -reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AeDebug\AutoExclusionList" /v "ctest.ext" /t REG_DWORD /d 1 -cd Build -if "%CONFIGURATION%"=="Debug" ( - if "%coverage%"=="1" ( - ctest -j 2 -C %CONFIGURATION% -D ExperimentalMemCheck -LE uses-signals || exit /b !ERRORLEVEL! - python ..\tools\misc\appveyorMergeCoverageScript.py || exit /b !ERRORLEVEL! - codecov --root .. --no-color --disable gcov -f cobertura.xml -t %CODECOV_TOKEN% || exit /b !ERRORLEVEL! - ) else ( - ctest -j 2 -C %CONFIGURATION% || exit /b !ERRORLEVEL! - ) -) -if "%CONFIGURATION%"=="Release" ( - ctest -j 2 -C %CONFIGURATION% || exit /b !ERRORLEVEL! -) diff --git a/tools/misc/coverage-helper.cpp b/tools/misc/coverage-helper.cpp deleted file mode 100644 index 9e7a8ca4..00000000 --- a/tools/misc/coverage-helper.cpp +++ /dev/null @@ -1,142 +0,0 @@ -#include <algorithm> -#include <array> -#include <cassert> -#include <fstream> -#include <iostream> -#include <memory> -#include <numeric> -#include <regex> -#include <string> -#include <vector> - -std::string escape_arg(const std::string& arg) { - if (arg.empty() == false && - arg.find_first_of(" \t\n\v\"") == arg.npos) { - return arg; - } - - std::string escaped; - escaped.push_back('"'); - for (auto it = arg.begin(); ; ++it) { - int num_backslashes = 0; - - while (it != arg.end() && *it == '\\') { - ++it; - ++num_backslashes; - } - - if (it == arg.end()) { - escaped.append(num_backslashes * 2, '\\'); - break; - } else if (*it == '"') { - escaped.append((num_backslashes + 1) * 2, '\\'); - escaped.push_back('"'); - escaped.push_back(*it); - } else { - escaped.append(num_backslashes, '\\'); - escaped.push_back(*it); - } - } - escaped.push_back('"'); - - return escaped; -} - - -void create_empty_file(std::string const& path) { - std::ofstream ofs(path); - ofs << '\n'; -} - -const std::string separator = "--sep--"; -const std::string logfile_prefix = "--log-file="; - -bool starts_with(std::string const& str, std::string const& pref) { - return str.find(pref) == 0; -} - -int parse_log_file_arg(std::string const& arg) { - assert(starts_with(arg, logfile_prefix) && "Attempting to parse incorrect arg!"); - auto fname = arg.substr(logfile_prefix.size()); - create_empty_file(fname); - std::regex regex("MemoryChecker\\.(\\d+)\\.log", std::regex::icase); - std::smatch match; - if (std::regex_search(fname, match, regex)) { - return std::stoi(match[1]); - } else { - throw std::domain_error("Couldn't find desired expression in string: " + fname); - } -} - -std::string catch_path(std::string path) { - auto start = path.find("catch"); - // try capitalized instead - if (start == std::string::npos) { - start = path.find("Catch"); - } - if (start == std::string::npos) { - throw std::domain_error("Couldn't find Catch's base path"); - } - auto end = path.find_first_of("\\/", start); - return path.substr(0, end); -} - -std::string windowsify_path(std::string path) { - for (auto& c : path) { - if (c == '/') { - c = '\\'; - } - } - return path; -} - -int exec_cmd(std::string const& cmd, int log_num, std::string const& path) { - std::array<char, 128> buffer; - - // cmd has already been escaped outside this function. - auto real_cmd = "OpenCppCoverage --export_type binary:cov-report" + std::to_string(log_num) - + ".bin --quiet " + "--sources " + escape_arg(path) + "\\src" + " --cover_children -- " + cmd; - std::cout << "=== Marker ===: Cmd: " << real_cmd << '\n'; - auto pipe = _popen(real_cmd.c_str(), "r"); - - if (!pipe) { - throw std::runtime_error("popen() failed!"); - } - while (!feof(pipe)) { - if (fgets(buffer.data(), 128, pipe) != nullptr) { - std::cout << buffer.data(); - } - } - - auto ret = _pclose(pipe); - if (ret == -1) { - throw std::runtime_error("underlying error in pclose()"); - } - - return ret; -} - -// argv should be: -// [0]: our path -// [1]: "--log-file=<path>" -// [2]: "--sep--" -// [3]+: the actual command - -int main(int argc, char** argv) { - std::vector<std::string> args(argv, argv + argc); - auto sep = std::find(begin(args), end(args), separator); - assert(sep - begin(args) == 2 && "Structure differs from expected!"); - - auto num = parse_log_file_arg(args[1]); - - auto cmdline = std::accumulate(++sep, end(args), std::string{}, [] (const std::string& lhs, const std::string& rhs) { - return lhs + ' ' + escape_arg(rhs); - }); - - try { - return exec_cmd(cmdline, num, windowsify_path(catch_path(args[0]))); - } catch (std::exception const& ex) { - std::cerr << "Helper failed with: '" << ex.what() << "'\n"; - return 12; - } -} diff --git a/tools/misc/installOpenCppCoverage.ps1 b/tools/misc/installOpenCppCoverage.ps1 deleted file mode 100644 index 795b7c8e..00000000 --- a/tools/misc/installOpenCppCoverage.ps1 +++ /dev/null @@ -1,19 +0,0 @@ -# Downloads are done from the official github release page links -$downloadUrl = "https://github.com/OpenCppCoverage/OpenCppCoverage/releases/download/release-0.9.9.0/OpenCppCoverageSetup-x64-0.9.9.0.exe" -$installerPath = [System.IO.Path]::Combine($Env:USERPROFILE, "Downloads", "OpenCppCoverageSetup.exe") - -if(-Not (Test-Path $installerPath)) { - Write-Host -ForegroundColor White ("Downloading OpenCppCoverage from: " + $downloadUrl) - Start-BitsTransfer $downloadUrl -Destination $installerPath -} - -Write-Host -ForegroundColor White "About to install OpenCppCoverage..." - -$installProcess = (Start-Process $installerPath -ArgumentList '/VERYSILENT' -PassThru -Wait) -if($installProcess.ExitCode -ne 0) { - throw [System.String]::Format("Failed to install OpenCppCoverage, ExitCode: {0}.", $installProcess.ExitCode) -} - -# Assume standard, boring, installation path of ".../Program Files/OpenCppCoverage" -$installPath = [System.IO.Path]::Combine(${Env:ProgramFiles}, "OpenCppCoverage") -$env:Path="$env:Path;$installPath" diff --git a/tools/scripts/developBuild.py b/tools/scripts/developBuild.py deleted file mode 100755 index 8837770c..00000000 --- a/tools/scripts/developBuild.py +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env python3 - -import releaseCommon - -v = releaseCommon.Version() -v.incrementBuildNumber() -releaseCommon.performUpdates(v) - -print( "Updated files to v{0}".format( v.getVersionString() ) ) diff --git a/tools/scripts/extractFeaturesFromReleaseNotes.py b/tools/scripts/extractFeaturesFromReleaseNotes.py deleted file mode 100644 index d8be0437..00000000 --- a/tools/scripts/extractFeaturesFromReleaseNotes.py +++ /dev/null @@ -1,92 +0,0 @@ -#!/usr/bin/env python3 - -# -# extractFeaturesFromReleaseNotes.py -# -# Read the release notes - docs/release-notes.md - and generate text -# for pasting in to individual documentation pages, to indicate which -# versions recent features were released in. -# -# Using the output of the file is easier than manually constructing -# the text to paste in to documentation pages. -# -# One way to use this: -# - run this script, saving the output to some temporary file -# - diff this output with the actual release notes page -# - the differences are Markdown text that can be pasted in to the -# appropriate documentation pages in the docs/ directory. -# - each release also has a github link to show which documentation files -# were changed in it. -# This can be helpful to see which documentation pages -# to add the 'Introduced in Catch ...' snippets to the relevant pages. -# - -import re - - -def create_introduced_in_text(version, bug_number = None): - """Generate text to paste in to documentation file""" - if bug_number: - return '> [Introduced](https://github.com/catchorg/Catch2/issues/%s) in Catch %s.' % (bug_number, version) - else: - # Use this text for changes that don't have issue numbers - return '> Introduced in Catch %s.' % version - - -def link_to_changes_in_release(release, releases): - """ - Markdown text for a hyperlink showing all edits in a release, or empty string - - :param release: A release version, as a string - :param releases: A container of releases, in descending order - newest to oldest - :return: Markdown text for a hyperlink showing the differences between the give release and the prior one, - or empty string, if the previous release is not known - """ - - if release == releases[-1]: - # This is the earliest release we know about - return '' - index = releases.index(release) - previous_release = releases[index + 1] - return '\n[Changes in %s](https://github.com/catchorg/Catch2/compare/v%s...v%s)' % (release, previous_release, release) - - -def write_recent_release_notes_with_introduced_text(): - current_version = None - release_toc_regex = r'\[(\d.\d.\d)\]\(#\d+\)<br>' - issue_number_regex = r'#[0-9]+' - releases = [] - with open('../docs/release-notes.md') as release_notes: - for line in release_notes: - line = line[:-1] - print(line) - - # Extract version number from table of contents - match = re.search(release_toc_regex, line) - if match: - release_name = match.group(1) - releases.append(release_name) - - if line.startswith('## '): - # It's a section with version number - current_version = line.replace('## ', '') - - # We decided not to add released-date info for older versions - if current_version == 'Older versions': - break - - print(create_introduced_in_text(current_version)) - print(link_to_changes_in_release(current_version, releases)) - - # Not yet found a version number, so to avoid picking up hyperlinks to - # version numbers in the index, keep going - if not current_version: - continue - - for bug_link in re.findall(issue_number_regex, line): - bug_number = bug_link.replace('#', '') - print(create_introduced_in_text(current_version, bug_number)) - - -if __name__ == '__main__': - write_recent_release_notes_with_introduced_text() diff --git a/tools/scripts/generateAmalgamatedFiles.py b/tools/scripts/generateAmalgamatedFiles.py index 5fed3358..2d40bcb4 100755 --- a/tools/scripts/generateAmalgamatedFiles.py +++ b/tools/scripts/generateAmalgamatedFiles.py @@ -39,7 +39,7 @@ file_header = '''\ // SPDX-License-Identifier: BSL-1.0 -// Catch v{version_string} +// Catch3 v{catch3_version}, on the Catch2 v{version_string} engine // Generated: {generation_time} // ---------------------------------------------------------- // This file is an amalgamation of multiple different files. @@ -54,8 +54,17 @@ file_header = '''\ # REUSE-IgnoreEnd # Returns file header with proper version string and generation time +def catch3_version(): + version_file = os.path.join(root_path, 'Progmasoft', 'Catch3', 'Version.hpp') + with open(version_file, mode='r', encoding='utf-8') as input: + match = re.search(r'kVersion = "([^"]+)"', input.read()) + if not match: + raise RuntimeError('no kVersion in ' + version_file) + return match.group(1) + def formatted_file_header(version): return file_header.format(version_string=version.getVersionString(), + catch3_version=catch3_version(), generation_time=datetime.datetime.now()) # Which headers were already concatenated (and thus should not be diff --git a/tools/scripts/majorRelease.py b/tools/scripts/majorRelease.py deleted file mode 100755 index eb712b46..00000000 --- a/tools/scripts/majorRelease.py +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env python3 - -import releaseCommon - -v = releaseCommon.Version() -v.incrementMajorVersion() -releaseCommon.performUpdates(v) - -print( "Updated files to v{0}".format( v.getVersionString() ) ) diff --git a/tools/scripts/minorRelease.py b/tools/scripts/minorRelease.py deleted file mode 100755 index 0992c8fb..00000000 --- a/tools/scripts/minorRelease.py +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env python3 - -import releaseCommon - -v = releaseCommon.Version() -v.incrementMinorVersion() -releaseCommon.performUpdates(v) - -print( "Updated files to v{0}".format( v.getVersionString() ) ) diff --git a/tools/scripts/patchRelease.py b/tools/scripts/patchRelease.py deleted file mode 100755 index 48256c15..00000000 --- a/tools/scripts/patchRelease.py +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env python3 - -import releaseCommon - -v = releaseCommon.Version() -v.incrementPatchNumber() -releaseCommon.performUpdates(v) - -print( "Updated files to v{0}".format( v.getVersionString() ) ) diff --git a/tools/scripts/releaseCommon.py b/tools/scripts/releaseCommon.py index 920fb98c..cbdd92e1 100644 --- a/tools/scripts/releaseCommon.py +++ b/tools/scripts/releaseCommon.py @@ -1,19 +1,14 @@ import os import re -import string -import fnmatch from scriptCommon import catchPath versionParser = re.compile( r'(\s*static\sVersion\sversion)\s*\(\s*(.*)\s*,\s*(.*)\s*,\s*(.*)\s*,\s*\"(.*)\"\s*,\s*(.*)\s*\).*' ) rootPath = os.path.join( catchPath, 'src/catch2' ) versionPath = os.path.join( rootPath, "catch_version.cpp" ) -definePath = os.path.join(rootPath, 'catch_version_macros.hpp') -readmePath = os.path.join( catchPath, "README.md" ) -cmakePath = os.path.join(catchPath, 'CMakeLists.txt') -mesonPath = os.path.join(catchPath, 'meson.build') class Version: + """The version of the Catch2 compatibility engine, from catch_version.cpp.""" def __init__(self): f = open( versionPath, 'r' ) for line in f: @@ -27,117 +22,8 @@ class Version: self.buildNumber = int(m.group(6)) f.close() - def nonDevelopRelease(self): - if self.branchName != "": - self.branchName = "" - self.buildNumber = 0 - def developBuild(self): - if self.branchName == "": - self.branchName = "develop" - self.buildNumber = 0 - - def incrementBuildNumber(self): - self.developBuild() - self.buildNumber = self.buildNumber+1 - - def incrementPatchNumber(self): - self.nonDevelopRelease() - self.patchNumber = self.patchNumber+1 - - def incrementMinorVersion(self): - self.nonDevelopRelease() - self.patchNumber = 0 - self.minorVersion = self.minorVersion+1 - - def incrementMajorVersion(self): - self.nonDevelopRelease() - self.patchNumber = 0 - self.minorVersion = 0 - self.majorVersion = self.majorVersion+1 - def getVersionString(self): versionString = '{0}.{1}.{2}'.format( self.majorVersion, self.minorVersion, self.patchNumber ) if self.branchName != "": versionString = versionString + '-{0}.{1}'.format( self.branchName, self.buildNumber ) return versionString - - def updateVersionFile(self): - f = open( versionPath, 'r' ) - lines = [] - for line in f: - m = versionParser.match( line ) - if m: - lines.append( '{0}( {1}, {2}, {3}, "{4}", {5} );'.format( self.variableDecl, self.majorVersion, self.minorVersion, self.patchNumber, self.branchName, self.buildNumber ) ) - else: - lines.append( line.rstrip() ) - f.close() - f = open( versionPath, 'w' ) - for line in lines: - f.write( line + "\n" ) - - -def updateCmakeFile(version): - with open(cmakePath, 'rb') as file: - lines = file.readlines() - replacementRegex = re.compile(b'''VERSION (\\d+.\\d+.\\d+) # CML version placeholder, don't delete''') - replacement = '''VERSION {0} # CML version placeholder, don't delete'''.format(version.getVersionString()).encode('ascii') - with open(cmakePath, 'wb') as file: - for line in lines: - file.write(replacementRegex.sub(replacement, line)) - - -def updateMesonFile(version): - with open(mesonPath, 'rb') as file: - lines = file.readlines() - replacementRegex = re.compile(b'''version\\s*:\\s*'(\\d+.\\d+.\\d+)', # CML version placeholder, don't delete''') - replacement = '''version: '{0}', # CML version placeholder, don't delete'''.format(version.getVersionString()).encode('ascii') - with open(mesonPath, 'wb') as file: - for line in lines: - file.write(replacementRegex.sub(replacement, line)) - - -def updateVersionDefine(version): - # First member of the tuple is the compiled regex object, the second is replacement if it matches - replacementRegexes = [(re.compile(b'#define CATCH_VERSION_MAJOR \\d+'),'#define CATCH_VERSION_MAJOR {}'.format(version.majorVersion).encode('ascii')), - (re.compile(b'#define CATCH_VERSION_MINOR \\d+'),'#define CATCH_VERSION_MINOR {}'.format(version.minorVersion).encode('ascii')), - (re.compile(b'#define CATCH_VERSION_PATCH \\d+'),'#define CATCH_VERSION_PATCH {}'.format(version.patchNumber).encode('ascii')), - ] - with open(definePath, 'rb') as file: - lines = file.readlines() - with open(definePath, 'wb') as file: - for line in lines: - for replacement in replacementRegexes: - line = replacement[0].sub(replacement[1], line) - file.write(line) - - -def updateVersionPlaceholder(filename, version): - with open(filename, 'rb') as file: - lines = file.readlines() - placeholderRegex = re.compile(b'Catch[0-9]? v?X.Y.Z') - replacement = 'Catch2 {}.{}.{}'.format(version.majorVersion, version.minorVersion, version.patchNumber).encode('ascii') - with open(filename, 'wb') as file: - for line in lines: - file.write(placeholderRegex.sub(replacement, line)) - - -def updateDocumentationVersionPlaceholders(version): - print('Updating version placeholder in documentation') - docsPath = os.path.join(catchPath, 'docs/') - for basePath, _, files in os.walk(docsPath): - for file in files: - if fnmatch.fnmatch(file, "*.md") and "contributing.md" != file: - updateVersionPlaceholder(os.path.join(basePath, file), version) - - -def performUpdates(version): - version.updateVersionFile() - updateVersionDefine(version) - - import generateAmalgamatedFiles - generateAmalgamatedFiles.generate_header() - generateAmalgamatedFiles.generate_cpp() - - updateCmakeFile(version) - updateMesonFile(version) - updateDocumentationVersionPlaceholders(version) |