mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-05 17:40:39 +00:00
Copy catch.hpp into qrenderdoc and run on --unittest in non-release
This commit is contained in:
@@ -152,7 +152,7 @@ jobs:
|
||||
- if: matrix.configuration == 'Development'
|
||||
name: Running UI unit tests
|
||||
run: |
|
||||
if ! ./*/Development/qrenderdoc.exe --unittest test.log; then
|
||||
if ! ./*/Development/qrenderdoc.exe --unittest log=test.log; then
|
||||
echo "::error::$(cat test.log)" | tr -d '\r' | tr '\n' '\001' | sed -e 's#\x01#%0D%0A#g';
|
||||
exit 1;
|
||||
fi
|
||||
@@ -240,7 +240,7 @@ jobs:
|
||||
- if: matrix.type == 'Debug'
|
||||
name: Run UI unit tests
|
||||
run: |
|
||||
if ! ./build/bin/qrenderdoc --unittest test.log; then
|
||||
if ! ./build/bin/qrenderdoc --unittest log=test.log; then
|
||||
echo "::error::$(cat test.log)" | tr '\n' '\001' | sed -e 's#\x01#%0A#g';
|
||||
exit 1;
|
||||
fi
|
||||
@@ -312,7 +312,7 @@ jobs:
|
||||
- if: matrix.type == 'Debug'
|
||||
name: Run UI unit tests
|
||||
run: |
|
||||
if ! ./build/bin/qrenderdoc.app/Contents/MacOS/qrenderdoc --unittest test.log; then
|
||||
if ! ./build/bin/qrenderdoc.app/Contents/MacOS/qrenderdoc --unittest log=test.log; then
|
||||
echo "::error::$(cat test.log)" | tr '\n' '\001' | sed -e $'s#\x01#%0A#g';
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
Permission is hereby granted, free of charge, to any person or organization
|
||||
obtaining a copy of the software and accompanying documentation covered by
|
||||
this license (the "Software") to use, reproduce, display, distribute,
|
||||
execute, and transmit the Software, and to prepare derivative works of the
|
||||
Software, and to permit third-parties to whom the Software is furnished to
|
||||
do so, all subject to the following:
|
||||
|
||||
The copyright notices in the Software and this entire statement, including
|
||||
the above license grant, this restriction and the following disclaimer,
|
||||
must be included in all copies of the Software, in whole or in part, and
|
||||
all derivative works of the Software, unless such copies or derivative
|
||||
works are solely in the form of machine-executable object code generated by
|
||||
a source language processor.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
Vendored
+68
@@ -0,0 +1,68 @@
|
||||
/******************************************************************************
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2018-2022 Baldur Karlsson
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
******************************************************************************/
|
||||
|
||||
// this file exists just to wrap the *real* catch.hpp and define any configuration defines we always
|
||||
// want on.
|
||||
|
||||
#define CATCH_CONFIG_FALLBACK_STRINGIFIER ToStrAsStdString
|
||||
#define CATCH_CONFIG_FORCE_FALLBACK_STRINGIFIER
|
||||
#define CATCH_CONFIG_INLINE_DEBUG_BREAK
|
||||
|
||||
// define the debugbreak to not be in a lambda, so that we get the right stack frame!
|
||||
#define CATCH_BREAK_INTO_DEBUGGER() \
|
||||
if(Catch::isDebuggerActive()) \
|
||||
{ \
|
||||
CATCH_TRAP(); \
|
||||
}
|
||||
|
||||
#include "renderdoc_replay.h"
|
||||
|
||||
#include <ostream>
|
||||
#include <string>
|
||||
|
||||
template <typename T>
|
||||
std::string ToStrAsStdString(const T &el)
|
||||
{
|
||||
rdcstr s = ToStr(el);
|
||||
return std::string(s.begin(), s.end());
|
||||
}
|
||||
|
||||
inline std::ostream &operator<<(std::ostream &os, rdcstr const &str)
|
||||
{
|
||||
return os << std::string(str.begin(), str.end());
|
||||
}
|
||||
|
||||
#include "official/catch.hpp"
|
||||
|
||||
namespace Catch
|
||||
{
|
||||
template <>
|
||||
struct StringMaker<rdcstr>
|
||||
{
|
||||
static std::string convert(rdcstr const &value)
|
||||
{
|
||||
return std::string(value.begin(), value.end());
|
||||
}
|
||||
};
|
||||
}
|
||||
+17998
File diff suppressed because it is too large
Load Diff
@@ -37,6 +37,12 @@
|
||||
#include <QStyledItemDelegate>
|
||||
#include "Code/Interface/QRDInterface.h"
|
||||
|
||||
#if !defined(RELEASE)
|
||||
#define ENABLE_UNIT_TESTS 1
|
||||
#else
|
||||
#define ENABLE_UNIT_TESTS 0
|
||||
#endif
|
||||
|
||||
class QHeaderView;
|
||||
|
||||
template <typename T>
|
||||
|
||||
+149
-25
@@ -39,6 +39,78 @@
|
||||
#include "Windows/MainWindow.h"
|
||||
#include "version.h"
|
||||
|
||||
#if ENABLE_UNIT_TESTS
|
||||
|
||||
#define CATCH_CONFIG_RUNNER
|
||||
#define CATCH_CONFIG_NOSTDOUT
|
||||
|
||||
#include "3rdparty/catch/catch.hpp"
|
||||
|
||||
// since we force use of ToStr for everything and don't allow using catch's stringstream (so that
|
||||
// enums get forwarded to ToStr) we need to implement ToStr for one of Catch's structs.
|
||||
template <>
|
||||
rdcstr DoStringise(const Catch::SourceLineInfo &el)
|
||||
{
|
||||
return QFormatStr("%1:%2").arg(QString::fromUtf8(el.file)).arg(el.line);
|
||||
}
|
||||
|
||||
class LogOutputter : public std::stringbuf
|
||||
{
|
||||
FILE *file;
|
||||
|
||||
public:
|
||||
LogOutputter(FILE *f) : file(f) {}
|
||||
void finish()
|
||||
{
|
||||
std::string msg = this->str();
|
||||
RENDERDOC_LogMessage(LogType::Comment, "EXTN", __FILE__, __LINE__, msg.c_str());
|
||||
fputs(msg.c_str(), file);
|
||||
}
|
||||
virtual int sync() override
|
||||
{
|
||||
rdcstr str = this->str().c_str();
|
||||
int idx = str.indexOf('\n');
|
||||
if(idx >= 0)
|
||||
{
|
||||
rdcstr msg = str.substr(0, idx + 1);
|
||||
RENDERDOC_LogMessage(LogType::Comment, "EXTN", __FILE__, __LINE__, msg);
|
||||
fputs(msg.c_str(), file);
|
||||
str = str.substr(idx + 1);
|
||||
this->str("");
|
||||
this->sputn(str.c_str(), str.size());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// force a sync on every output
|
||||
virtual std::streamsize xsputn(const char *s, std::streamsize n) override
|
||||
{
|
||||
std::streamsize ret = std::stringbuf::xsputn(s, n);
|
||||
sync();
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
std::ostream *catch_stream = NULL;
|
||||
|
||||
namespace Catch
|
||||
{
|
||||
std::ostream &cout()
|
||||
{
|
||||
return *catch_stream;
|
||||
}
|
||||
std::ostream &cerr()
|
||||
{
|
||||
return *catch_stream;
|
||||
}
|
||||
std::ostream &clog()
|
||||
{
|
||||
return *catch_stream;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(Q_OS_WIN32)
|
||||
extern "C" {
|
||||
_declspec(dllexport) unsigned long NvOptimusEnablement = 0x00000001;
|
||||
@@ -107,43 +179,95 @@ int main(int argc, char *argv[])
|
||||
QApplication::setApplicationVersion(lit(FULL_VERSION_STRING));
|
||||
|
||||
// shortcut here so we can run this with a non-GUI application
|
||||
#if !defined(RELEASE)
|
||||
#if ENABLE_UNIT_TESTS
|
||||
if(QString::fromUtf8(argv[1]) == lit("--unittest"))
|
||||
{
|
||||
QCoreApplication application(argc, argv);
|
||||
PythonContext::GlobalInit();
|
||||
char **mod_argv = new char *[argc + 1];
|
||||
char **alloc_argv = mod_argv;
|
||||
for(int i = 0; i < argc; i++)
|
||||
mod_argv[i] = argv[i];
|
||||
mod_argv[argc] = 0;
|
||||
|
||||
bool errors = false;
|
||||
// pop --unittest
|
||||
argc--;
|
||||
mod_argv++;
|
||||
|
||||
FILE *logOut = NULL;
|
||||
|
||||
if(argc >= 3)
|
||||
logOut = fopen(argv[2], "w");
|
||||
|
||||
if(logOut == NULL)
|
||||
logOut = stdout;
|
||||
|
||||
fputs("Checking python binding consistency.\n", logOut);
|
||||
|
||||
rdcstr errorLog;
|
||||
FILE *test_logOut = NULL;
|
||||
|
||||
if(argc >= 2 && QString::fromUtf8(mod_argv[1]).left(4) == lit("log="))
|
||||
{
|
||||
PythonContextHandle py;
|
||||
errors = py.ctx().CheckInterfaces(errorLog);
|
||||
test_logOut = fopen(mod_argv[1] + 4, "w");
|
||||
|
||||
// pop
|
||||
argc--;
|
||||
mod_argv++;
|
||||
}
|
||||
|
||||
if(errors)
|
||||
mod_argv[0] = argv[0];
|
||||
|
||||
if(test_logOut == NULL)
|
||||
test_logOut = stdout;
|
||||
|
||||
LogOutputter logbuf(test_logOut);
|
||||
std::ostream logstream(&logbuf);
|
||||
|
||||
int ret = 0;
|
||||
|
||||
// catch tests first
|
||||
{
|
||||
RENDERDOC_LogMessage(LogType::Error, "EXTN", __FILE__, __LINE__, errorLog);
|
||||
fputs("Found errors in python bindings. Please fix!\n", logOut);
|
||||
fputs(errorLog.c_str(), logOut);
|
||||
return 1;
|
||||
catch_stream = &logstream;
|
||||
|
||||
Catch::Session session;
|
||||
|
||||
session.configData().name = "QRenderDoc";
|
||||
session.configData().shouldDebugBreak = Catch::isDebuggerActive();
|
||||
|
||||
ret = session.applyCommandLine(argc, mod_argv);
|
||||
|
||||
if(ret == 0)
|
||||
{
|
||||
int numFailed = session.run();
|
||||
|
||||
// Note that on unices only the lower 8 bits are usually used, clamping
|
||||
// the return value to 255 prevents false negative when some multiple
|
||||
// of 256 tests has failed
|
||||
if(numFailed != 0)
|
||||
ret = (numFailed < 0xff ? numFailed : 0xff);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
{
|
||||
fputs("Python bindings are consistent.\n", logOut);
|
||||
return 0;
|
||||
QCoreApplication application(argc, mod_argv);
|
||||
PythonContext::GlobalInit();
|
||||
|
||||
logstream << "Checking python binding consistency.\n";
|
||||
|
||||
rdcstr errorLog;
|
||||
bool errors = false;
|
||||
{
|
||||
PythonContextHandle py;
|
||||
errors = py.ctx().CheckInterfaces(errorLog);
|
||||
}
|
||||
|
||||
if(errors)
|
||||
{
|
||||
logstream << errorLog;
|
||||
qCritical() << "Found errors in python bindings. Please fix!\n";
|
||||
ret = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
logstream << "Python bindings are consistent.\n";
|
||||
ret = 0;
|
||||
}
|
||||
}
|
||||
|
||||
logbuf.finish();
|
||||
|
||||
delete[] alloc_argv;
|
||||
|
||||
fclose(test_logOut);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -817,6 +817,8 @@
|
||||
<ClCompile Include="Code\qrenderdoc.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="3rdparty\catch\catch.hpp" />
|
||||
<ClInclude Include="3rdparty\catch\official\catch.hpp" />
|
||||
<ClInclude Include="3rdparty\scintilla\include\ILexer.h" />
|
||||
<ClInclude Include="3rdparty\scintilla\include\Platform.h" />
|
||||
<ClInclude Include="3rdparty\scintilla\include\qt\ScintillaDocument.h" />
|
||||
|
||||
@@ -82,6 +82,9 @@
|
||||
<Filter Include="Resources\Files">
|
||||
<UniqueIdentifier>{c6877252-7f18-4c63-a2f7-66b1913d8ada}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="3rdparty\catch">
|
||||
<UniqueIdentifier>{3e544acc-65a0-4558-8a31-8865c030e996}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="3rdparty\toolwindowmanager\ToolWindowManager.cpp">
|
||||
@@ -1133,6 +1136,12 @@
|
||||
<ClInclude Include="$(IntDir)generated\ui_ShaderMessageViewer.h">
|
||||
<Filter>Generated Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="3rdparty\catch\catch.hpp">
|
||||
<Filter>3rdparty\catch</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="3rdparty\catch\official\catch.hpp">
|
||||
<Filter>3rdparty\catch</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Code\pyrenderdoc\pyconversion.h">
|
||||
|
||||
Reference in New Issue
Block a user