Headless: Add specific GitHub Actions logging.

This commit is contained in:
Unknown W. Brackets committed 2020-12-31 00:21:09 -08:00
1 parent af7c97d624
commit c73d8ab1d0
3 files changed
+32 -13

No files matched your search

+21 -3
View File
@@ -33,7 +33,7 @@
#include <vector>
bool teamCityMode = false;
std::string teamCityName = "";
std::string currentTestName = "";
void TeamCityPrint(const char *fmt, ...)
{
@@ -52,6 +52,22 @@ void TeamCityPrint(const char *fmt, ...)
printf("##teamcity[%s]\n", temp);
}
void GitHubActionsPrint(const char *type, const char *fmt, ...) {
if (!getenv("GITHUB_ACTIONS"))
return;
const int TEMP_BUFFER_SIZE = 32768;
char temp[TEMP_BUFFER_SIZE];
va_list args;
va_start(args, fmt);
vsnprintf(temp, TEMP_BUFFER_SIZE - 1, fmt, args);
temp[TEMP_BUFFER_SIZE - 1] = '\0';
va_end(args);
printf("::%s::%s\n", type, temp);
}
struct BufferedLineReader {
const static int MAX_BUFFER = 5;
const static int TEMP_BUFFER_SIZE = 32768;
@@ -223,7 +239,8 @@ bool CompareOutput(const std::string &bootFilename, const std::string &output, b
if (!failed)
{
TeamCityPrint("testFailed name='%s' message='Output different from expected file'", teamCityName.c_str());
TeamCityPrint("testFailed name='%s' message='Output different from expected file'", currentTestName.c_str());
GitHubActionsPrint("error", "Incorrect output for %s", currentTestName.c_str());
failed = true;
}
@@ -277,7 +294,8 @@ bool CompareOutput(const std::string &bootFilename, const std::string &output, b
else
{
fprintf(stderr, "Expectation file %s not found\n", expect_filename.c_str());
TeamCityPrint("testIgnored name='%s' message='Expects file missing'", teamCityName.c_str());
TeamCityPrint("testIgnored name='%s' message='Expects file missing'", currentTestName.c_str());
GitHubActionsPrint("error", "Expected file missing for %s", currentTestName.c_str());
return false;
}
}
+3 -2
View File
@@ -23,8 +23,9 @@
struct GPUDebugBuffer;
extern bool teamCityMode;
extern std::string teamCityName;
extern std::string currentTestName;
void TeamCityPrint(const char *fmt, ...);
void GitHubActionsPrint(const char *type, const char *fmt, ...);
std::string ExpectedFromFilename(const std::string &bootFilename);
std::string ExpectedScreenshotFromFilename(const std::string &bootFilename);
@@ -32,4 +33,4 @@ std::string GetTestName(const std::string &bootFilename);
bool CompareOutput(const std::string &bootFilename, const std::string &output, bool verbose);
std::vector<u32> TranslateDebugBufferToCompare(const GPUDebugBuffer *buffer, u32 stride, u32 h);
double CompareScreenshot(const std::vector<u32> &pixels, u32 stride, u32 w, u32 h, const std::string& screenshotFilename, std::string &error);
double CompareScreenshot(const std::vector<u32> &pixels, u32 stride, u32 w, u32 h, const std::string& screenshotFilename, std::string &error);
+8 -8
View File
@@ -148,10 +148,8 @@ static HeadlessHost *getHost(GPUCore gpuCore) {
bool RunAutoTest(HeadlessHost *headlessHost, CoreParameter &coreParameter, bool autoCompare, bool verbose, double timeout)
{
if (teamCityMode) {
// Kinda ugly, trying to guesstimate the test name from filename...
teamCityName = GetTestName(coreParameter.fileToStart);
}
// Kinda ugly, trying to guesstimate the test name from filename...
currentTestName = GetTestName(coreParameter.fileToStart);
std::string output;
if (autoCompare)
@@ -161,11 +159,12 @@ bool RunAutoTest(HeadlessHost *headlessHost, CoreParameter &coreParameter, bool
if (!PSP_Init(coreParameter, &error_string)) {
fprintf(stderr, "Failed to start %s. Error: %s\n", coreParameter.fileToStart.c_str(), error_string.c_str());
printf("TESTERROR\n");
TeamCityPrint("testIgnored name='%s' message='PRX/ELF missing'", teamCityName.c_str());
TeamCityPrint("testIgnored name='%s' message='PRX/ELF missing'", currentTestName.c_str());
GitHubActionsPrint("error", "PRX/ELF missing for %s", currentTestName.c_str());
return false;
}
TeamCityPrint("testStarted name='%s' captureStandardOutput='true'", teamCityName.c_str());
TeamCityPrint("testStarted name='%s' captureStandardOutput='true'", currentTestName.c_str());
host->BootDone();
@@ -201,7 +200,8 @@ bool RunAutoTest(HeadlessHost *headlessHost, CoreParameter &coreParameter, bool
passed = false;
host->SendDebugOutput("TIMEOUT\n");
TeamCityPrint("testFailed name='%s' message='Test timeout'", teamCityName.c_str());
TeamCityPrint("testFailed name='%s' message='Test timeout'", currentTestName.c_str());
GitHubActionsPrint("error", "Test timeout for %s", currentTestName.c_str());
Core_Stop();
}
}
@@ -217,7 +217,7 @@ bool RunAutoTest(HeadlessHost *headlessHost, CoreParameter &coreParameter, bool
if (autoCompare && passed)
passed = CompareOutput(coreParameter.fileToStart, output, verbose);
TeamCityPrint("testFinished name='%s'", teamCityName.c_str());
TeamCityPrint("testFinished name='%s'", currentTestName.c_str());
return passed;
}