Skip to content

Commit

Permalink
Merge pull request #1985 from AllenInstitute/bugfix/1985-checklogfile…
Browse files Browse the repository at this point in the history
…s-test

Tests/CheckLogFiles: Fix the test
  • Loading branch information
t-b authored Feb 7, 2024
2 parents a98dc05 + a033d01 commit 18133d2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
23 changes: 18 additions & 5 deletions Packages/tests/Basic/UTF_Utils.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -7391,12 +7391,13 @@ End

static Function CheckLogFiles()

string file, line
variable foundFiles, jsonID

// ensure that the ZeroMQ logfile exists as well
// and also have the right layout
PrepareForPublishTest()

string file
variable foundFiles, jsonID

WAVE/T filesAndOther = GetLogFileNames()
Duplicate/RMD=[][0]/FREE/T filesAndOther, files

Expand All @@ -7409,16 +7410,28 @@ static Function CheckLogFiles()
CHECK_WAVE(contents, TEXT_WAVE)
CHECK_GT_VAR(DimSize(contents, ROWS), 0)

if(!cmpstr(contents[0], "{}"))
for(line : contents)
if(cmpstr(line, "{}"))
break
endif
endfor

if(!cmpstr(line, "{}"))
// only {} inside the file, no need to check for timestamp
continue
endif

jsonID = JSON_Parse(contents[0])
jsonID = JSON_Parse(line)
CHECK(JSON_IsValid(jsonID))

INFO("File: \"%s\", Line: \"%s\"", s0 = file, s1 = line)

CHECK(MIES_LOG#LOG_HasRequiredKeys(jsonID))
WAVE/T keys = JSON_GetKeys(jsonID, "")
FindValue/TEXT="ts" keys

INFO("File: \"%s\", Line: \"%s\"", s0 = file, s1 = line)

CHECK_GE_VAR(V_Value, 0)

foundFiles += 1
Expand Down
2 changes: 2 additions & 0 deletions Packages/tests/UTF_HelperFunctions.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ End

Function PrepareForPublishTest()

UpdateXOPLoggingTemplate()

variable numTrials = StartZeroMQSockets(forceRestart = 1)
REQUIRE_EQUAL_VAR(numTrials, 0)

Expand Down

0 comments on commit 18133d2

Please sign in to comment.