commit cvise for openSUSE:Factory
Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package cvise for openSUSE:Factory checked in at 2024-06-27 16:04:46 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/cvise (Old) and /work/SRC/openSUSE:Factory/.cvise.new.18349 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "cvise" Thu Jun 27 16:04:46 2024 rev:79 rq:1183541 version:2.10.0+git.20240603.16a34b2 Changes: -------- --- /work/SRC/openSUSE:Factory/cvise/cvise.changes 2024-04-23 18:57:43.190029043 +0200 +++ /work/SRC/openSUSE:Factory/.cvise.new.18349/cvise.changes 2024-06-27 16:05:22.907194831 +0200 @@ -1,0 +2,24 @@ +Thu Jun 27 07:38:28 UTC 2024 - martin.liska@hey.com + +- Update to version 2.10.0+git.20240603.16a34b2: + * Fix fallout from ClassTemplateSpecializationDecl::getTypeAsWritten + * Remove uses of ClassTemplateSpecializationDecl::getTypeAsWritten (#143) + * Fix deprecated decl (#141) + * Move to ubuntu:rolling again + * Add VSCode settings file + * Add Dockerfile for LLVM tip builds + +------------------------------------------------------------------- +Mon May 06 19:22:59 UTC 2024 - martin.liska@hey.com + +- Update to version 2.10.0+git.20240506.fd50de2: + * Manipulate with tempfiles after they are closed (#139) + * Fix --print-diff after pathlib has been used + * Apply Ruff format + * Reduce logging output verbosity + * Fix Ruff linter issues + * Stick to Ubuntu 23.10 + * Ensure that clang delta is also compiled with C++17 on Windows + * Also instruct to install chardet on Windows + +------------------------------------------------------------------- Old: ---- cvise-2.10.0+git.20240415.00bdd8c.tar.xz New: ---- cvise-2.10.0+git.20240603.16a34b2.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ cvise.spec ++++++ --- /var/tmp/diff_new_pack.9CNEOV/_old 2024-06-27 16:05:23.851229492 +0200 +++ /var/tmp/diff_new_pack.9CNEOV/_new 2024-06-27 16:05:23.851229492 +0200 @@ -17,7 +17,7 @@ Name: cvise -Version: 2.10.0+git.20240415.00bdd8c +Version: 2.10.0+git.20240603.16a34b2 Release: 0 Summary: Super-parallel Python port of the C-Reduce License: BSD-3-Clause ++++++ _servicedata ++++++ --- /var/tmp/diff_new_pack.9CNEOV/_old 2024-06-27 16:05:23.903231401 +0200 +++ /var/tmp/diff_new_pack.9CNEOV/_new 2024-06-27 16:05:23.907231548 +0200 @@ -1,6 +1,6 @@ <servicedata> <service name="tar_scm"> <param name="url">https://github.com/marxin/cvise</param> - <param name="changesrevision">00bdd8c1f9824002b10ac5fecd31dff6c5bef671</param></service></servicedata> + <param name="changesrevision">16a34b273966e32843b3f193590198e2a769b1b0</param></service></servicedata> (No newline at EOF) ++++++ cvise-2.10.0+git.20240415.00bdd8c.tar.xz -> cvise-2.10.0+git.20240603.16a34b2.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cvise-2.10.0+git.20240415.00bdd8c/.github/workflows/build-llvm-nightly.yml new/cvise-2.10.0+git.20240603.16a34b2/.github/workflows/build-llvm-nightly.yml --- old/cvise-2.10.0+git.20240415.00bdd8c/.github/workflows/build-llvm-nightly.yml 2024-04-15 13:06:47.000000000 +0200 +++ new/cvise-2.10.0+git.20240603.16a34b2/.github/workflows/build-llvm-nightly.yml 2024-06-03 12:35:00.000000000 +0200 @@ -29,6 +29,8 @@ - run: chmod +x llvm.sh - run: ./llvm.sh 19 - run: apt-get install -y bolt-19 clang-19 libclang-common-19-dev libclang-19-dev mlir-19-tools llvm-19-tools libclang-common-19-dev libclang-19-dev libclang1-19 clang-format-19 python3-clang-19 clangd-19 clang-tidy-19 libomp-19-dev + # TODO: remove in the future + - run: touch /usr/lib/llvm-19/lib/libLibcTableGenUtil.a - uses: actions/checkout@v4 - run: mkdir objdir - run: cmake .. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cvise-2.10.0+git.20240415.00bdd8c/.gitignore new/cvise-2.10.0+git.20240603.16a34b2/.gitignore --- old/cvise-2.10.0+git.20240415.00bdd8c/.gitignore 2024-04-15 13:06:47.000000000 +0200 +++ new/cvise-2.10.0+git.20240603.16a34b2/.gitignore 2024-06-03 12:35:00.000000000 +0200 @@ -22,7 +22,6 @@ *.vcxproj *.vcxproj.filters *.sln -.vscode ## Ignore Visual Studio temporary files, build results, and ## files generated by popular Visual Studio add-ons. @@ -40,6 +39,7 @@ x86/ objdir/ build/ +build-docker/ # Visual Studio 2015 cache/options directory .vs/ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cvise-2.10.0+git.20240415.00bdd8c/.vscode/settings.json new/cvise-2.10.0+git.20240603.16a34b2/.vscode/settings.json --- old/cvise-2.10.0+git.20240415.00bdd8c/.vscode/settings.json 1970-01-01 01:00:00.000000000 +0100 +++ new/cvise-2.10.0+git.20240603.16a34b2/.vscode/settings.json 2024-06-03 12:35:00.000000000 +0200 @@ -0,0 +1,4 @@ +{ + "C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools", + "editor.formatOnSave": false +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cvise-2.10.0+git.20240415.00bdd8c/CMakeLists.txt new/cvise-2.10.0+git.20240603.16a34b2/CMakeLists.txt --- old/cvise-2.10.0+git.20240415.00bdd8c/CMakeLists.txt 2024-04-15 13:06:47.000000000 +0200 +++ new/cvise-2.10.0+git.20240603.16a34b2/CMakeLists.txt 2024-06-03 12:35:00.000000000 +0200 @@ -190,6 +190,8 @@ set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3") set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELEASE} -O3 -g") +elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++17 /GR-") endif() ############################################################################### diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cvise-2.10.0+git.20240415.00bdd8c/Dockerfile new/cvise-2.10.0+git.20240603.16a34b2/Dockerfile --- old/cvise-2.10.0+git.20240415.00bdd8c/Dockerfile 1970-01-01 01:00:00.000000000 +0100 +++ new/cvise-2.10.0+git.20240603.16a34b2/Dockerfile 2024-06-03 12:35:00.000000000 +0200 @@ -0,0 +1,10 @@ +FROM ubuntu:rolling +RUN apt-get update +RUN apt-get -qq install -y gcc g++ wget lsb-release wget software-properties-common gnupg git cmake flex python3-pebble python3-psutil python3-chardet python3-pytest vim unifdef +RUN wget https://apt.llvm.org/llvm.sh +RUN chmod +x llvm.sh +RUN ./llvm.sh 19 +RUN apt-get install -y bolt-19 clang-19 libclang-common-19-dev libclang-19-dev mlir-19-tools llvm-19-tools libclang-common-19-dev libclang-19-dev libclang1-19 clang-format-19 python3-clang-19 clangd-19 clang-tidy-19 libomp-19-dev +RUN touch /usr/lib/llvm-19/lib/libLibcTableGenUtil.a +RUN mkdir -p /tmp/cvise/build-docker +WORKDIR /tmp/cvise/build-docker diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cvise-2.10.0+git.20240415.00bdd8c/INSTALL.md new/cvise-2.10.0+git.20240603.16a34b2/INSTALL.md --- old/cvise-2.10.0+git.20240415.00bdd8c/INSTALL.md 2024-04-15 13:06:47.000000000 +0200 +++ new/cvise-2.10.0+git.20240603.16a34b2/INSTALL.md 2024-06-03 12:35:00.000000000 +0200 @@ -159,7 +159,7 @@ Download flex from https://github.com/lexxmark/winflexbison/releases/download/v2.5.24/win_flex_... ``` -pip install pytest psutil pebble +pip install pytest psutil pebble chardet @call "%PROGRAMFILES(x86)%\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x86_amd64 set LLVM_DIR=D:\src\llvm-project\build\lib\cmake\llvm set CLANG_DIR=D:\src\llvm-project\build\lib\cmake\clang diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cvise-2.10.0+git.20240415.00bdd8c/clang_delta/CMakeLists.txt new/cvise-2.10.0+git.20240603.16a34b2/clang_delta/CMakeLists.txt --- old/cvise-2.10.0+git.20240415.00bdd8c/clang_delta/CMakeLists.txt 2024-04-15 13:06:47.000000000 +0200 +++ new/cvise-2.10.0+git.20240603.16a34b2/clang_delta/CMakeLists.txt 2024-06-03 12:35:00.000000000 +0200 @@ -728,7 +728,7 @@ foreach(flag ${msvc_warning_flags}) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag}") - set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} ${flag}") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}") endforeach(flag) endif(MSVC) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cvise-2.10.0+git.20240415.00bdd8c/clang_delta/CommonRenameClassRewriteVisitor.h new/cvise-2.10.0+git.20240603.16a34b2/clang_delta/CommonRenameClassRewriteVisitor.h --- old/cvise-2.10.0+git.20240415.00bdd8c/clang_delta/CommonRenameClassRewriteVisitor.h 2024-04-15 13:06:47.000000000 +0200 +++ new/cvise-2.10.0+git.20240603.16a34b2/clang_delta/CommonRenameClassRewriteVisitor.h 2024-06-03 12:35:00.000000000 +0200 @@ -56,9 +56,10 @@ bool VisitDependentTemplateSpecializationTypeLoc( DependentTemplateSpecializationTypeLoc DTSLoc); - +#if LLVM_VERSION_MAJOR < 19 bool VisitClassTemplatePartialSpecializationDecl( ClassTemplatePartialSpecializationDecl *D); +#endif bool VisitClassTemplateSpecializationDecl( ClassTemplateSpecializationDecl *TSD); @@ -122,6 +123,7 @@ return true; } +#if LLVM_VERSION_MAJOR < 19 template<typename T> bool CommonRenameClassRewriteVisitor<T>:: VisitClassTemplatePartialSpecializationDecl( @@ -154,6 +156,7 @@ } return true; } +#endif // ISSUE: I am not sure why, but RecursiveASTVisitor doesn't recursively // visit base classes from explicit template specialization, e.g., @@ -162,6 +165,8 @@ // template<> class B : public A<short> { }; // In the above case, A<short> won't be touched. // So we have to do it manually + +#if LLVM_VERSION_MAJOR < 19 template<typename T> bool CommonRenameClassRewriteVisitor<T>::VisitClassTemplateSpecializationDecl( ClassTemplateSpecializationDecl *TSD) @@ -177,6 +182,33 @@ } return true; } +#else +template<typename T> +bool CommonRenameClassRewriteVisitor<T>::VisitClassTemplateSpecializationDecl( + ClassTemplateSpecializationDecl *TSD) +{ + if (!TSD->isExplicitInstantiationOrSpecialization()) + return true; + + const CXXRecordDecl *CXXRD = TSD->getSpecializedTemplate()->getTemplatedDecl(); + std::string Name; + if (getNewName(CXXRD, Name)) { + SourceLocation LocStart = TSD->getLocation(); + TransAssert(LocStart.isValid() && "Invalid Location!"); + TheRewriter->ReplaceText(LocStart, CXXRD->getNameAsString().size(), Name); + } + + if (TSD->isExplicitSpecialization() && TSD->isCompleteDefinition()) { + for (CXXRecordDecl::base_class_const_iterator I = TSD->bases_begin(), + E = TSD->bases_end(); I != E; ++I) { + TypeSourceInfo *TSI = (*I).getTypeSourceInfo(); + TransAssert(TSI && "Bad TypeSourceInfo!"); + getDerived().TraverseTypeLoc(TSI->getTypeLoc()); + } + } + return true; +} +#endif template<typename T> bool CommonRenameClassRewriteVisitor<T>::VisitCXXRecordDecl( diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cvise-2.10.0+git.20240415.00bdd8c/clang_delta/RemoveNamespace.cpp new/cvise-2.10.0+git.20240603.16a34b2/clang_delta/RemoveNamespace.cpp --- old/cvise-2.10.0+git.20240415.00bdd8c/clang_delta/RemoveNamespace.cpp 2024-04-15 13:06:47.000000000 +0200 +++ new/cvise-2.10.0+git.20240603.16a34b2/clang_delta/RemoveNamespace.cpp 2024-06-03 12:35:00.000000000 +0200 @@ -91,9 +91,6 @@ bool VisitTemplateSpecializationTypeLoc( TemplateSpecializationTypeLoc TSPLoc); - bool VisitClassTemplatePartialSpecializationDecl( - ClassTemplatePartialSpecializationDecl *D); - bool VisitDependentTemplateSpecializationTypeLoc( DependentTemplateSpecializationTypeLoc DTSLoc); @@ -132,14 +129,25 @@ bool RemoveNamespaceRewriteVisitor::VisitClassTemplateSpecializationDecl( ClassTemplateSpecializationDecl *TSD) { - if (!TSD->isExplicitSpecialization() || !TSD->isCompleteDefinition()) + if (!TSD->isExplicitInstantiationOrSpecialization()) return true; - for (CXXRecordDecl::base_class_const_iterator I = TSD->bases_begin(), - E = TSD->bases_end(); I != E; ++I) { - TypeSourceInfo *TSI = (*I).getTypeSourceInfo(); - TransAssert(TSI && "Bad TypeSourceInfo!"); - TraverseTypeLoc(TSI->getTypeLoc()); + const CXXRecordDecl *CXXRD = TSD->getSpecializedTemplate()->getTemplatedDecl(); + std::string Name; + if (ConsumerInstance->getNewName(CXXRD, Name)) { + SourceLocation LocStart = TSD->getLocation(); + TransAssert(LocStart.isValid() && "Invalid Location!"); + ConsumerInstance->TheRewriter.ReplaceText( + LocStart, CXXRD->getNameAsString().size(), Name); + } + + if (TSD->isExplicitSpecialization() && TSD->isCompleteDefinition()) { + for (CXXRecordDecl::base_class_const_iterator I = TSD->bases_begin(), + E = TSD->bases_end(); I != E; ++I) { + TypeSourceInfo *TSI = (*I).getTypeSourceInfo(); + TransAssert(TSI && "Bad TypeSourceInfo!"); + TraverseTypeLoc(TSI->getTypeLoc()); + } } return true; } @@ -419,38 +427,6 @@ return true; } -bool RemoveNamespaceRewriteVisitor::VisitClassTemplatePartialSpecializationDecl( - ClassTemplatePartialSpecializationDecl *D) -{ - const Type *Ty = D->getInjectedSpecializationType().getTypePtr(); - TransAssert(Ty && "Bad TypePtr!"); - const TemplateSpecializationType *TST = - dyn_cast<TemplateSpecializationType>(Ty); - TransAssert(TST && "Bad TemplateSpecializationType!"); - - TemplateName TplName = TST->getTemplateName(); - const TemplateDecl *TplD = TplName.getAsTemplateDecl(); - TransAssert(TplD && "Invalid TemplateDecl!"); - NamedDecl *ND = TplD->getTemplatedDecl(); - TransAssert(ND && "Invalid NamedDecl!"); - - const CXXRecordDecl *CXXRD = dyn_cast<CXXRecordDecl>(ND); - TransAssert(CXXRD && "Invalid CXXRecordDecl!"); - - std::string Name; - if (ConsumerInstance->getNewName(CXXRD, Name)) { - const TypeSourceInfo *TyInfo = D->getTypeAsWritten(); - if (!TyInfo) - return true; - TypeLoc TyLoc = TyInfo->getTypeLoc(); - SourceLocation LocStart = TyLoc.getBeginLoc(); - TransAssert(LocStart.isValid() && "Invalid Location!"); - ConsumerInstance->TheRewriter.ReplaceText( - LocStart, CXXRD->getNameAsString().size(), Name); - } - return true; -} - // handle the case where a template specialization type cannot be resolved, e.g. // template <class T> struct Base {}; // template <class T> struct Derived: public Base<T> { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cvise-2.10.0+git.20240415.00bdd8c/clang_delta/RenameCXXMethod.cpp new/cvise-2.10.0+git.20240603.16a34b2/clang_delta/RenameCXXMethod.cpp --- old/cvise-2.10.0+git.20240415.00bdd8c/clang_delta/RenameCXXMethod.cpp 2024-04-15 13:06:47.000000000 +0200 +++ new/cvise-2.10.0+git.20240603.16a34b2/clang_delta/RenameCXXMethod.cpp 2024-06-03 12:35:00.000000000 +0200 @@ -426,7 +426,7 @@ { size_t PrefixLen = MethodNamePrefix.length(); StringRef NamePrefix = Name.substr(0, PrefixLen); - if (!NamePrefix.equals(MethodNamePrefix)) + if (NamePrefix != MethodNamePrefix) return false; llvm::APInt Num; return !Name.drop_front(PrefixLen).getAsInteger(10, Num); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cvise-2.10.0+git.20240415.00bdd8c/cvise/cvise.py new/cvise-2.10.0+git.20240603.16a34b2/cvise/cvise.py --- old/cvise-2.10.0+git.20240415.00bdd8c/cvise/cvise.py 2024-04-15 13:06:47.000000000 +0200 +++ new/cvise-2.10.0+git.20240603.16a34b2/cvise/cvise.py 2024-06-03 12:35:00.000000000 +0200 @@ -195,8 +195,8 @@ improvement = ( self.test_manager.orig_total_file_size - total_file_size ) / self.test_manager.orig_total_file_size - logging.info( - f'Termination check: stopping threshold is {self.test_manager.stopping_threshold}; current improvement is {improvement}' + logging.debug( + f'Termination check: stopping threshold is {self.test_manager.stopping_threshold}; current improvement is {improvement:.1f}' ) if improvement >= self.test_manager.stopping_threshold: met_stopping_threshold = True diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cvise-2.10.0+git.20240415.00bdd8c/cvise/passes/clang.py new/cvise-2.10.0+git.20240603.16a34b2/cvise/passes/clang.py --- old/cvise-2.10.0+git.20240415.00bdd8c/cvise/passes/clang.py 2024-04-15 13:06:47.000000000 +0200 +++ new/cvise-2.10.0+git.20240603.16a34b2/cvise/passes/clang.py 2024-06-03 12:35:00.000000000 +0200 @@ -1,9 +1,9 @@ import logging import os import shutil -import tempfile from cvise.passes.abstract import AbstractPass, PassResult +from cvise.utils.misc import CloseableTemporaryFile class ClangPass(AbstractPass): @@ -21,7 +21,7 @@ def transform(self, test_case, state, process_event_notifier): tmp = os.path.dirname(test_case) - with tempfile.NamedTemporaryFile(mode='w', delete=False, dir=tmp) as tmp_file: + with CloseableTemporaryFile(mode='w', dir=tmp) as tmp_file: args = [ self.external_programs['clang_delta'], f'--transformation={self.arg}', @@ -33,13 +33,13 @@ logging.debug(' '.join(cmd)) - stdout, _stderr, returncode = process_event_notifier.run_process(cmd) + stdout, _, returncode = process_event_notifier.run_process(cmd) if returncode == 0: tmp_file.write(stdout) - shutil.move(tmp_file.name, test_case) + tmp_file.close() + shutil.copy(tmp_file.name, test_case) return (PassResult.OK, state) else: - os.unlink(tmp_file.name) if returncode == 255 or returncode == 1: return (PassResult.STOP, state) else: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cvise-2.10.0+git.20240415.00bdd8c/cvise/passes/clangbinarysearch.py new/cvise-2.10.0+git.20240603.16a34b2/cvise/passes/clangbinarysearch.py --- old/cvise-2.10.0+git.20240415.00bdd8c/cvise/passes/clangbinarysearch.py 2024-04-15 13:06:47.000000000 +0200 +++ new/cvise-2.10.0+git.20240603.16a34b2/cvise/passes/clangbinarysearch.py 2024-06-03 12:35:00.000000000 +0200 @@ -3,10 +3,10 @@ import re import shutil import subprocess -import tempfile import time from cvise.passes.abstract import AbstractPass, BinaryState, PassResult +from cvise.utils.misc import CloseableTemporaryFile class ClangBinarySearchPass(AbstractPass): @@ -97,7 +97,7 @@ logging.debug(f'TRANSFORM: {state}') tmp = os.path.dirname(test_case) - with tempfile.NamedTemporaryFile(mode='w', delete=False, dir=tmp) as tmp_file: + with CloseableTemporaryFile(mode='w', dir=tmp) as tmp_file: args = [ f'--transformation={self.arg}', f'--counter={state.index + 1}', @@ -115,11 +115,11 @@ stdout, stderr, returncode = process_event_notifier.run_process(cmd) self.parse_stderr(state, stderr) tmp_file.write(stdout) + tmp_file.close() if returncode == 0: - shutil.move(tmp_file.name, test_case) + shutil.copy(tmp_file.name, test_case) return (PassResult.OK, state) else: - os.unlink(tmp_file.name) return ( PassResult.STOP if returncode == 255 else PassResult.ERROR, state, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cvise-2.10.0+git.20240415.00bdd8c/cvise/passes/clex.py new/cvise-2.10.0+git.20240603.16a34b2/cvise/passes/clex.py --- old/cvise-2.10.0+git.20240415.00bdd8c/cvise/passes/clex.py 2024-04-15 13:06:47.000000000 +0200 +++ new/cvise-2.10.0+git.20240603.16a34b2/cvise/passes/clex.py 2024-06-03 12:35:00.000000000 +0200 @@ -1,8 +1,8 @@ import os import shutil -import tempfile from cvise.passes.abstract import AbstractPass, PassResult +from cvise.utils.misc import CloseableTemporaryFile class ClexPass(AbstractPass): @@ -20,15 +20,15 @@ def transform(self, test_case, state, process_event_notifier): tmp = os.path.dirname(test_case) - with tempfile.NamedTemporaryFile(mode='w', delete=False, dir=tmp) as tmp_file: + with CloseableTemporaryFile(mode='w', dir=tmp) as tmp_file: cmd = [self.external_programs['clex'], str(self.arg), str(state), test_case] stdout, _stderr, returncode = process_event_notifier.run_process(cmd) if returncode == 51: tmp_file.write(stdout) - shutil.move(tmp_file.name, test_case) + tmp_file.close() + shutil.copy(tmp_file.name, test_case) return (PassResult.OK, state) else: - os.unlink(tmp_file.name) return ( PassResult.STOP if returncode == 71 else PassResult.ERROR, state, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cvise-2.10.0+git.20240415.00bdd8c/cvise/passes/lines.py new/cvise-2.10.0+git.20240603.16a34b2/cvise/passes/lines.py --- old/cvise-2.10.0+git.20240415.00bdd8c/cvise/passes/lines.py 2024-04-15 13:06:47.000000000 +0200 +++ new/cvise-2.10.0+git.20240603.16a34b2/cvise/passes/lines.py 2024-06-03 12:35:00.000000000 +0200 @@ -6,6 +6,7 @@ from cvise.passes.abstract import AbstractPass, BinaryState, PassResult from cvise.utils.error import InsaneTestCaseError +from cvise.utils.misc import CloseableTemporaryFile class LinesPass(AbstractPass): @@ -15,9 +16,10 @@ def __format(self, test_case, check_sanity): tmp = os.path.dirname(test_case) - with tempfile.NamedTemporaryFile(mode='w+', dir=tmp) as backup, tempfile.NamedTemporaryFile( + with CloseableTemporaryFile(mode='w+', dir=tmp) as backup, CloseableTemporaryFile( mode='w+', dir=tmp ) as tmp_file: + backup.close() with open(test_case) as in_file: try: cmd = [self.external_programs['topformflat'], self.arg] @@ -28,7 +30,7 @@ for line in proc.stdout.splitlines(keepends=True): if not line.isspace(): tmp_file.write(line) - tmp_file.flush() + tmp_file.close() # we need to check that sanity check is still fine if check_sanity: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cvise-2.10.0+git.20240415.00bdd8c/cvise/passes/unifdef.py new/cvise-2.10.0+git.20240603.16a34b2/cvise/passes/unifdef.py --- old/cvise-2.10.0+git.20240415.00bdd8c/cvise/passes/unifdef.py 2024-04-15 13:06:47.000000000 +0200 +++ new/cvise-2.10.0+git.20240603.16a34b2/cvise/passes/unifdef.py 2024-06-03 12:35:00.000000000 +0200 @@ -36,6 +36,7 @@ tmp = os.path.dirname(test_case) with tempfile.NamedTemporaryFile(mode='w+', delete=False, dir=tmp) as tmp_file: + tmp_file.close() while True: du = '-D' if state % 2 == 0 else '-U' n_index = int(state / 2) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cvise-2.10.0+git.20240415.00bdd8c/cvise/utils/misc.py new/cvise-2.10.0+git.20240603.16a34b2/cvise/utils/misc.py --- old/cvise-2.10.0+git.20240415.00bdd8c/cvise/utils/misc.py 2024-04-15 13:06:47.000000000 +0200 +++ new/cvise-2.10.0+git.20240603.16a34b2/cvise/utils/misc.py 2024-06-03 12:35:00.000000000 +0200 @@ -1,6 +1,24 @@ +import os +import tempfile +from contextlib import contextmanager + + def is_readable_file(filename): try: open(filename).read() return True except UnicodeDecodeError: return False + + +# TODO: use tempfile.NamedTemporaryFile(delete_on_close=False) since Python 3.12 is the oldest supported release +@contextmanager +def CloseableTemporaryFile(mode='w+b', dir=None): + f = tempfile.NamedTemporaryFile(mode=mode, delete=False, dir=dir) + try: + yield f + finally: + # For Windows systems, be sure we always close the file before we remove it! + if not f.closed: + f.close() + os.remove(f.name) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cvise-2.10.0+git.20240415.00bdd8c/cvise/utils/testing.py new/cvise-2.10.0+git.20240603.16a34b2/cvise/utils/testing.py --- old/cvise-2.10.0+git.20240415.00bdd8c/cvise/utils/testing.py 2024-04-15 13:06:47.000000000 +0200 +++ new/cvise-2.10.0+git.20240603.16a34b2/cvise/utils/testing.py 2024-06-03 12:35:00.000000000 +0200 @@ -197,7 +197,7 @@ def create_root(self): pass_name = str(self.current_pass).replace('::', '-') self.root = tempfile.mkdtemp(prefix=f'{self.TEMP_PREFIX}{pass_name}-') - logging.debug('Creating pass root folder: %s' % self.root) + logging.debug(f'Creating pass root folder: {self.root}') def remove_root(self): if not self.save_temps: @@ -294,10 +294,10 @@ ) with (crash_dir / 'PASS_BUG_INFO.TXT').open(mode='w') as info_file: - info_file.write('Package: %s\n' % CVise.Info.PACKAGE_STRING) - info_file.write('Git version: %s\n' % CVise.Info.GIT_VERSION) - info_file.write('LLVM version: %s\n' % CVise.Info.LLVM_VERSION) - info_file.write('System: %s\n' % str(platform.uname())) + info_file.write(f'Package: {CVise.Info.PACKAGE_STRING}\n') + info_file.write(f'Git version: {CVise.Info.GIT_VERSION}\n') + info_file.write(f'LLVM version: {CVise.Info.LLVM_VERSION}\n') + info_file.write(f'System: {str(platform.uname())}\n') info_file.write(PassBugError.MSG.format(self.current_pass, problem, test_env.state, crash_dir)) if self.die_on_pass_bug: @@ -313,7 +313,7 @@ with open(changed_file) as f: changed_file_lines = f.readlines() - diffed_lines = difflib.unified_diff(orig_file_lines, changed_file_lines, orig_file, changed_file) + diffed_lines = difflib.unified_diff(orig_file_lines, changed_file_lines, str(orig_file), str(changed_file)) return ''.join(diffed_lines) @@ -345,7 +345,7 @@ @classmethod def log_key_event(cls, event): - logging.info('****** %s ******' % event) + logging.info(f'****** {event} ******') def kill_pid_queue(self): active_pids = set() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cvise-2.10.0+git.20240415.00bdd8c/cvise.py new/cvise-2.10.0+git.20240603.16a34b2/cvise.py --- old/cvise-2.10.0+git.20240415.00bdd8c/cvise.py 2024-04-15 13:06:47.000000000 +0200 +++ new/cvise-2.10.0+git.20240603.16a34b2/cvise.py 2024-06-03 12:35:00.000000000 +0200 @@ -150,17 +150,14 @@ return 1 -EPILOG_TEXT = ( - """ +EPILOG_TEXT = f""" available shortcuts: S - skip execution of the current pass D - toggle --print-diff option For bug reporting instructions, please use: -%s +{CVise.Info.PACKAGE_URL} """ - % CVise.Info.PACKAGE_URL -) if __name__ == '__main__': parser = argparse.ArgumentParser( @@ -312,7 +309,7 @@ '--version', action='version', version=CVise.Info.PACKAGE_STRING - + (' (%s)' % CVise.Info.GIT_VERSION if CVise.Info.GIT_VERSION != 'unknown' else ''), + + (f' ({CVise.Info.GIT_VERSION})' if CVise.Info.GIT_VERSION != 'unknown' else ''), ) parser.add_argument( '--commands', @@ -450,7 +447,7 @@ script.write(f'#!/usr/bin/env {args.shell}\n\n') script.write(args.commands + '\n') os.chmod(script.name, 0o744) - logging.info('Using temporary interestingness test: %s' % script.name) + logging.info(f'Using temporary interestingness test: {script.name}') args.interestingness_test = script.name test_manager = testing.TestManager(
participants (1)
-
Source-Sync