Skip to content

Commit

Permalink
debug CI
Browse files Browse the repository at this point in the history
  • Loading branch information
dhconnelly committed Nov 28, 2024
1 parent 790db0b commit 30e5ed0
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cmake-x86_64-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ jobs:
working-directory: ${{github.workspace}}/build
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest -C ${{env.BUILD_TYPE}} --rerun-failed --output-on-failure
run: ctest -V -C ${{env.BUILD_TYPE}} --rerun-failed --output-on-failure

16 changes: 15 additions & 1 deletion src/json/parser.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include "json/parser.h"

#include <cassert>
#include <cerrno>
#include <cstring>
#include <format>

#include "utils/logging.h"
Expand Down Expand Up @@ -251,9 +253,21 @@ ValuePtr Parse(FILE* f, int size) {
}

ValuePtr Parse(const std::string& s) {
LOG(DEBUG) << "parsing: [" << s << "]";
LOG(DEBUG) << "size of data: " << s.size();
std::unique_ptr<FILE, decltype(&fclose)> f(
fmemopen((void*)s.data(), s.size(), "r"), fclose);
if (f.get() == nullptr) throw SystemError(errno);
if (f.get() == nullptr) {
LOG(DEBUG) << "fmemopen error: " << strerror(errno);
throw SystemError(errno);
}
int c = fgetc(f.get());
if (c == EOF) {
LOG(DEBUG) << "first read got eof, errno " << strerror(errno);
} else {
LOG(DEBUG) << "first char: " << c << " [" << char(c) << ']';
ungetc(c, f.get());
}
return Parse(f.get(), s.size());
}

Expand Down
6 changes: 5 additions & 1 deletion src/json/parser_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
namespace gabby {
namespace json {

TEST(JSON, ParseNull) { EXPECT_EQ(*Value::Nil(), *Parse("null")); }
TEST(JSON, ParseNull) {
ScopedLogLevel scope(LogLevel::DEBUG);
EXPECT_EQ(*Value::Nil(), *Parse("null"));
}

TEST(JSON, ParseNumber) {
EXPECT_EQ(*Value::Number(0), *Parse("0"));
Expand Down Expand Up @@ -45,6 +48,7 @@ TEST(JSON, ParseObject) {
}

TEST(JSON, ParseCompletionRequest) {
ScopedLogLevel scope(LogLevel::DEBUG);
EXPECT_EQ(
*Value::Object({
{"model", Value::String("gabby-1")},
Expand Down

0 comments on commit 30e5ed0

Please sign in to comment.