Skip to content

Conversation

@aspiers
Copy link
Contributor

@aspiers aspiers commented Feb 2, 2020

This ensures that contracts using system.print won't break,
and that there is some mechanism for outputting to the logs
and STDOUT. Test suites which wish to avoid this can stub
system.print, e.g.

system.print = function(msg)
end

or

function stubPrint()
  system.origPrint = system.print
  system.print = function(msg)
    printOutput[#printOutput + 1] = msg
    -- We don't have the table library
    -- table.insert(printOutput, msg)
  end
end

function showPrintOutput()
  system.origPrint("captured:")
  for i, line in pairs(printOutput) do
    system.origPrint(line)
  end
  system.origPrint("--------")
end

function assertOutputContains(pattern)
  for i, line in pairs(printOutput) do
    if string.match(line, pattern) then
      return true
    end
  end
  error("Output did not contain '" .. pattern .. "'")
end

function resetOutputCapture()
  printOutput = {}
end

This ensures that contracts using system.print won't break,
and that there is some mechanism for outputting to the logs
and STDOUT.  Test suites which wish to avoid this can stub
system.print, e.g.

    system.print = function(msg)
    end

or

    function stubPrint()
      system.origPrint = system.print
      system.print = function(msg)
        printOutput[#printOutput + 1] = msg
        -- We don't have the table library
        -- table.insert(printOutput, msg)
      end
    end

    function showPrintOutput()
      system.origPrint("captured:")
      for i, line in pairs(printOutput) do
        system.origPrint(line)
      end
      system.origPrint("--------")
    end

    function assertOutputContains(pattern)
      for i, line in pairs(printOutput) do
        if string.match(line, pattern) then
          return true
        end
      end
      error("Output did not contain '" .. pattern .. "'")
    end

    function resetOutputCapture()
      printOutput = {}
    end
@codecov
Copy link

codecov bot commented Feb 2, 2020

Codecov Report

Merging #9 into develop will decrease coverage by 0.07%.
The diff coverage is 40%.

Impacted file tree graph

@@              Coverage Diff              @@
##             develop       #9      +/-   ##
=============================================
- Coverage      71.82%   71.75%   -0.08%     
  Complexity         2        2              
=============================================
  Files             98       98              
  Lines           2080     2085       +5     
  Branches         107      107              
=============================================
+ Hits            1494     1496       +2     
- Misses           510      513       +3     
  Partials          76       76
Impacted Files Coverage Δ Complexity Δ
core/src/main/java/ship/test/Athena.java 100% <100%> (ø) 0 <0> (ø) ⬇️
core/src/main/java/ship/test/AergoMock.java 27.27% <25%> (-0.51%) 0 <0> (ø)
core/src/main/java/ship/build/WebServer.java 72.22% <0%> (ø) 0% <0%> (ø) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bbdbd7c...f8d5060. Read the comment docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant