Browse Source

use love-test-report action

added md support to work with love-test-report, a basic action made to just dump md files into repo checks
ell 1 year ago
parent
commit
04293d3fbd

+ 13 - 11
.github/workflows/main.yml

@@ -205,14 +205,16 @@ jobs:
       with:
       with:
         name: love-windows-${{ steps.vars.outputs.arch }}${{ steps.vars.outputs.compatname }}-dbg
         name: love-windows-${{ steps.vars.outputs.arch }}${{ steps.vars.outputs.compatname }}-dbg
         path: pdb/Release/*.pdb
         path: pdb/Release/*.pdb
+    - name: Build Test Exe
+      run: cmake --build build --config Release --target install
     - name: Run All Tests
     - name: Run All Tests
-      run: love-windows-${{ steps.vars.outputs.arch }}${{ steps.vars.outputs.compatname }}.exe testing --console --runAllTests
-    - name: Test Report
-      uses: dorny/test-reporter@v1
+      run: install\love.exe testing --console --runAllTests
+    - name: Love Test Report
+      uses: ellraiser/love-test-report@main
       with:
       with:
-        name: Test Output
-        path: testing/output/*.xml
-        reporter: jest-junit
+        name: Love Testsuite Windows
+        title: windows-${{ steps.vars.outputs.arch }}${{ steps.vars.outputs.compatname }}-test-report
+        path: testing/output/lovetest_runAllTests.md
   macOS:
   macOS:
     runs-on: macos-latest
     runs-on: macos-latest
     steps:
     steps:
@@ -243,12 +245,12 @@ jobs:
         path: love-macos.zip
         path: love-macos.zip
     - name: Run All Tests
     - name: Run All Tests
       run: love-macos/love.app/Contents/MacOS/love testing --runAllTests
       run: love-macos/love.app/Contents/MacOS/love testing --runAllTests
-    - name: Test Report
-      uses: dorny/test-reporter@v1
+    - name: Love Test Report
+      uses: ellraiser/love-test-report@main
       with:
       with:
-        name: Test Output
-        path: testing/output/*.xml
-        reporter: jest-junit
+        name: Love Testsuite MacOS
+        title: macos-test-report
+        path: testing/output/lovetest_runAllTests.md
   iOS-Simulator:
   iOS-Simulator:
     runs-on: macos-latest
     runs-on: macos-latest
     steps:
     steps:

+ 1 - 0
.gitignore

@@ -71,3 +71,4 @@ stamp-h1
 .vscode/
 .vscode/
 /testing/output/*.xml
 /testing/output/*.xml
 /testing/output/*.html
 /testing/output/*.html
+/testing/output/*.md

+ 4 - 2
testing/classes/TestMethod.lua

@@ -303,18 +303,20 @@ TestMethod = {
     -- get failure/skip message for output (if any)
     -- get failure/skip message for output (if any)
     local failure = ''
     local failure = ''
     local output = ''
     local output = ''
-    -- @NOTE if you don't put anything inside of the <failure></failure> then
-    -- dorny/test-reporter@v1 will fail to parse it
     if self.passed == false and self.skipped == false then
     if self.passed == false and self.skipped == false then
       failure = '\t\t\t<failure message="' .. self.result.key .. ' ' ..
       failure = '\t\t\t<failure message="' .. self.result.key .. ' ' ..
         self.result.message .. '">' .. self.result.key .. ' ' .. self.result.message .. '</failure>\n'
         self.result.message .. '">' .. self.result.key .. ' ' .. self.result.message .. '</failure>\n'
         output = self.result.key .. ' ' ..  self.result.message
         output = self.result.key .. ' ' ..  self.result.message
+      -- append failures if any to report md
+      love.test.mdfailures = love.test.mdfailures .. '> 🔴 ' .. self.method .. '  \n' ..
+        '> ' .. output .. '  \n\n'
     end
     end
     if output == '' and self.skipped == true then
     if output == '' and self.skipped == true then
       failure = '\t\t\t<skipped message="' .. self.skipreason .. '" />\n'
       failure = '\t\t\t<skipped message="' .. self.skipreason .. '" />\n'
       output = self.skipreason
       output = self.skipreason
     end
     end
 
 
+
     -- append XML for the test class result
     -- append XML for the test class result
     self.testmodule.xml = self.testmodule.xml .. '\t\t<testcase classname="' ..
     self.testmodule.xml = self.testmodule.xml .. '\t\t<testcase classname="' ..
       self.method .. '" name="' .. self.method .. '" assertions="' .. tostring(#self.asserts) ..
       self.method .. '" name="' .. self.method .. '" assertions="' .. tostring(#self.asserts) ..

+ 9 - 2
testing/classes/TestModule.lua

@@ -84,6 +84,15 @@ TestModule = {
   -- @return {nil}
   -- @return {nil}
   printResult = function(self)
   printResult = function(self)
     local finaltime = UtilTimeFormat(self.time)
     local finaltime = UtilTimeFormat(self.time)
+    local status = '🔴'
+    if self.failed == 0 then status = '🟢' end
+    -- add md row to main output
+    love.test.mdrows = love.test.mdrows .. '| ' .. status .. 
+      ' love.' .. self.module .. 
+      ' | ' .. tostring(self.passed) .. 
+      ' | ' .. tostring(self.failed) .. 
+      ' | ' .. tostring(self.skipped) .. 
+      ' | ' .. finaltime .. 's |' .. '\n'
     -- add xml to main output
     -- add xml to main output
     love.test.xml = love.test.xml .. '\t<testsuite name="love.' .. self.module .. 
     love.test.xml = love.test.xml .. '\t<testsuite name="love.' .. self.module .. 
       '" tests="' .. tostring(self.passed) .. 
       '" tests="' .. tostring(self.passed) .. 
@@ -91,8 +100,6 @@ TestModule = {
       '" skipped="' .. tostring(self.skipped) ..
       '" skipped="' .. tostring(self.skipped) ..
       '" time="' .. finaltime .. '">\n' .. self.xml .. '\t</testsuite>\n'
       '" time="' .. finaltime .. '">\n' .. self.xml .. '\t</testsuite>\n'
     -- add html to main output
     -- add html to main output
-    local status = '🔴'
-    if self.failed == 0 then status = '🟢' end
     love.test.html = love.test.html .. '<h2>' .. status .. '&nbsp;love.' .. self.module .. '</h2><ul class="summary">' ..
     love.test.html = love.test.html .. '<h2>' .. status .. '&nbsp;love.' .. self.module .. '</h2><ul class="summary">' ..
       '<li>🟢&nbsp;' .. tostring(self.passed) .. ' Tests</li>' ..
       '<li>🟢&nbsp;' .. tostring(self.passed) .. ' Tests</li>' ..
       '<li>🔴&nbsp;' .. tostring(self.failed) .. ' Failures</li>' ..
       '<li>🔴&nbsp;' .. tostring(self.failed) .. ' Failures</li>' ..

+ 17 - 1
testing/classes/TestSuite.lua

@@ -17,6 +17,8 @@ TestSuite = {
       time = 0,
       time = 0,
       xml = '',
       xml = '',
       html = '',
       html = '',
+      mdrows = '',
+      mdfailures = '',
       fakequit = false,
       fakequit = false,
       windowmode = true,
       windowmode = true,
 
 
@@ -124,10 +126,23 @@ TestSuite = {
 
 
   -- @method - TestSuite:printResult()
   -- @method - TestSuite:printResult()
   -- @desc - prints the result of the whole test suite as well as writes
   -- @desc - prints the result of the whole test suite as well as writes
-  --         the XML + HTML of the testsuite output
+  --         the MD, XML + HTML of the testsuite output
   -- @return {nil}
   -- @return {nil}
   printResult = function(self)
   printResult = function(self)
     local finaltime = UtilTimeFormat(self.time)
     local finaltime = UtilTimeFormat(self.time)
+    
+    local md = '<!-- PASSED ' .. tostring(self.totals[1]) ..
+      ' || FAILED ' .. tostring(self.totals[2]) ..
+      ' || SKIPPED ' .. tostring(self.totals[3]) ..
+      ' || TIME ' .. finaltime .. ' -->\n\n' ..
+      '**' .. tostring(self.totals[1] + self.totals[2] + self.totals[3]) .. '** tests were completed in **' ..
+      finaltime .. 's** with **' ..
+      tostring(self.totals[1]) .. '** passed, **' ..
+      tostring(self.totals[2]) .. '** failed, and **' ..
+      tostring(self.totals[3]) .. '** skipped\n\n### Report\n' ..
+      '| Module                | Passed | Failed | Skipped | Time   |\n' ..
+      '| --------------------- | ------ | ------ | ------- | ------ |\n' ..
+      self.mdrows .. '\n\n### Failures\n' .. self.mdfailures
 
 
     local xml = '<testsuites name="love.test" tests="' .. tostring(self.totals[1]) .. 
     local xml = '<testsuites name="love.test" tests="' .. tostring(self.totals[1]) .. 
       '" failures="' .. tostring(self.totals[2]) .. 
       '" failures="' .. tostring(self.totals[2]) .. 
@@ -147,6 +162,7 @@ TestSuite = {
     love.filesystem.mountFullPath(love.filesystem.getSource() .. "/output", "tempoutput", "readwrite")
     love.filesystem.mountFullPath(love.filesystem.getSource() .. "/output", "tempoutput", "readwrite")
     love.filesystem.write('tempoutput/' .. self.output .. '.xml', xml .. self.xml .. '</testsuites>')
     love.filesystem.write('tempoutput/' .. self.output .. '.xml', xml .. self.xml .. '</testsuites>')
     love.filesystem.write('tempoutput/' .. self.output .. '.html', html .. self.html .. '</div></body></html>')
     love.filesystem.write('tempoutput/' .. self.output .. '.html', html .. self.html .. '</div></body></html>')
+    love.filesystem.write('tempoutput/' .. self.output .. '.md', md)
 
 
     self.module:log('grey', '\nFINISHED - ' .. finaltime .. 's\n')
     self.module:log('grey', '\nFINISHED - ' .. finaltime .. 's\n')
     local failedcol = '\27[31m'
     local failedcol = '\27[31m'

+ 1 - 1
testing/output/readme.md

@@ -1,2 +1,2 @@
 # Testing Output
 # Testing Output
-Any tests run will output an XML and HTML file here, assuming the tests are run with readwrite permissions for this repo
+Any tests run will output an XML, MD, and HTML file here, assuming the tests are run with readwrite permissions for this repo

+ 1 - 2
testing/todo.md

@@ -1,9 +1,8 @@
 `/Applications/love_12.app/Contents/MacOS/love ./testing`
 `/Applications/love_12.app/Contents/MacOS/love ./testing`
 
 
 ## Todo
 ## Todo
-- fix XML format
 - check test runs for windows setup
 - check test runs for windows setup
-- add runs for linux + ios
+- add runs for linux + ios?
 - finish graphics state methods
 - finish graphics state methods
 - start graphics drawing methods
 - start graphics drawing methods
 - start object methods
 - start object methods