parent
18b526b08a
commit
d6beccc445
2
Makefile
2
Makefile
|
@ -671,7 +671,7 @@ cli/threadexecutor.o: cli/threadexecutor.cpp cli/cppcheckexecutor.h cli/executor
|
||||||
test/fixture.o: test/fixture.cpp externals/tinyxml2/tinyxml2.h lib/check.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/importproject.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/standards.h lib/suppressions.h lib/utils.h test/fixture.h test/options.h test/redirect.h
|
test/fixture.o: test/fixture.cpp externals/tinyxml2/tinyxml2.h lib/check.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/importproject.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/standards.h lib/suppressions.h lib/utils.h test/fixture.h test/options.h test/redirect.h
|
||||||
$(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/fixture.cpp
|
$(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/fixture.cpp
|
||||||
|
|
||||||
test/helpers.o: test/helpers.cpp externals/simplecpp/simplecpp.h lib/config.h lib/errortypes.h lib/importproject.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/suppressions.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h test/helpers.h
|
test/helpers.o: test/helpers.cpp cli/filelister.h externals/simplecpp/simplecpp.h lib/config.h lib/errortypes.h lib/importproject.h lib/library.h lib/mathlib.h lib/path.h lib/pathmatch.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/suppressions.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h test/helpers.h
|
||||||
$(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/helpers.cpp
|
$(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/helpers.cpp
|
||||||
|
|
||||||
test/main.o: test/main.cpp externals/simplecpp/simplecpp.h lib/check.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/importproject.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/suppressions.h lib/utils.h test/fixture.h test/options.h
|
test/main.o: test/main.cpp externals/simplecpp/simplecpp.h lib/check.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/importproject.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/suppressions.h lib/utils.h test/fixture.h test/options.h
|
||||||
|
|
|
@ -18,7 +18,9 @@
|
||||||
|
|
||||||
#include "helpers.h"
|
#include "helpers.h"
|
||||||
|
|
||||||
|
#include "filelister.h"
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
|
#include "pathmatch.h"
|
||||||
#include "preprocessor.h"
|
#include "preprocessor.h"
|
||||||
|
|
||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
|
@ -26,6 +28,7 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream> // IWYU pragma: keep
|
#include <fstream> // IWYU pragma: keep
|
||||||
#include <list>
|
#include <list>
|
||||||
|
#include <map>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
@ -41,6 +44,7 @@
|
||||||
|
|
||||||
class Suppressions;
|
class Suppressions;
|
||||||
|
|
||||||
|
// TODO: better path-only usage
|
||||||
ScopedFile::ScopedFile(std::string name, const std::string &content, std::string path)
|
ScopedFile::ScopedFile(std::string name, const std::string &content, std::string path)
|
||||||
: mName(std::move(name))
|
: mName(std::move(name))
|
||||||
, mPath(Path::toNativeSeparators(std::move(path)))
|
, mPath(Path::toNativeSeparators(std::move(path)))
|
||||||
|
@ -65,18 +69,35 @@ ScopedFile::ScopedFile(std::string name, const std::string &content, std::string
|
||||||
ScopedFile::~ScopedFile() {
|
ScopedFile::~ScopedFile() {
|
||||||
const int remove_res = std::remove(mFullPath.c_str());
|
const int remove_res = std::remove(mFullPath.c_str());
|
||||||
if (remove_res != 0) {
|
if (remove_res != 0) {
|
||||||
std::cout << "ScopedFile(" << mFullPath + ") - could not delete file (" << remove_res << ")";
|
std::cout << "ScopedFile(" << mFullPath + ") - could not delete file (" << remove_res << ")" << std::endl;
|
||||||
}
|
}
|
||||||
if (!mPath.empty() && mPath != Path::getCurrentPath()) {
|
if (!mPath.empty() && mPath != Path::getCurrentPath()) {
|
||||||
|
// TODO: remove all files
|
||||||
|
// TODO: simplify the function call
|
||||||
|
// hack to be able to delete *.plist output files
|
||||||
|
std::map<std::string, std::size_t> files;
|
||||||
|
const std::string res = FileLister::addFiles(files, mPath, {".plist"}, false, PathMatch({}));
|
||||||
|
if (!res.empty()) {
|
||||||
|
std::cout << "ScopedFile(" << mPath + ") - generating file list failed (" << res << ")" << std::endl;
|
||||||
|
}
|
||||||
|
for (const auto &f : files)
|
||||||
|
{
|
||||||
|
const std::string &file = f.first;
|
||||||
|
const int rm_f_res = std::remove(file.c_str());
|
||||||
|
if (rm_f_res != 0) {
|
||||||
|
std::cout << "ScopedFile(" << mPath + ") - could not delete '" << file << "' (" << rm_f_res << ")" << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
if (!RemoveDirectoryA(mPath.c_str())) {
|
if (!RemoveDirectoryA(mPath.c_str())) {
|
||||||
std::cout << "ScopedFile(" << mFullPath + ") - could not delete folder (" << GetLastError() << ")";
|
std::cout << "ScopedFile(" << mFullPath + ") - could not delete folder (" << GetLastError() << ")" << std::endl;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
const int rmdir_res = rmdir(mPath.c_str());
|
const int rmdir_res = rmdir(mPath.c_str());
|
||||||
if (rmdir_res == -1) {
|
if (rmdir_res == -1) {
|
||||||
const int err = errno;
|
const int err = errno;
|
||||||
std::cout << "ScopedFile(" << mFullPath + ") - could not delete folder (" << err << ")";
|
std::cout << "ScopedFile(" << mFullPath + ") - could not delete folder (" << err << ")" << std::endl;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,8 +140,8 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void many_threads_plist() {
|
void many_threads_plist() {
|
||||||
const char plistOutput[] = "plist";
|
const char plistOutput[] = "plist_process/";
|
||||||
ScopedFile plistFile("dummy", plistOutput);
|
ScopedFile plistFile("dummy", "", plistOutput);
|
||||||
|
|
||||||
check(16, 100, 100,
|
check(16, 100, 100,
|
||||||
"int main()\n"
|
"int main()\n"
|
||||||
|
|
|
@ -182,15 +182,15 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void many_files_plist() {
|
void many_files_plist() {
|
||||||
const char plistOutput[] = "plist";
|
const std::string plistOutput = "plist_" + fprefix() + "/";
|
||||||
ScopedFile plistFile("dummy", plistOutput);
|
ScopedFile plistFile("dummy", "", plistOutput);
|
||||||
|
|
||||||
check(100, 100,
|
check(100, 100,
|
||||||
"int main()\n"
|
"int main()\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" char *a = malloc(10);\n"
|
" char *a = malloc(10);\n"
|
||||||
" return 0;\n"
|
" return 0;\n"
|
||||||
"}", dinit(CheckOptions, $.plistOutput = plistOutput));
|
"}", dinit(CheckOptions, $.plistOutput = plistOutput.c_str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void no_errors_more_files() {
|
void no_errors_more_files() {
|
||||||
|
|
|
@ -138,8 +138,8 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void many_threads_plist() {
|
void many_threads_plist() {
|
||||||
const char plistOutput[] = "plist";
|
const char plistOutput[] = "plist_thread/";
|
||||||
ScopedFile plistFile("dummy", plistOutput);
|
ScopedFile plistFile("dummy", "", plistOutput);
|
||||||
|
|
||||||
check(16, 100, 100,
|
check(16, 100, 100,
|
||||||
"int main()\n"
|
"int main()\n"
|
||||||
|
|
Loading…
Reference in New Issue