From f477b8085f945eeeadb4cede78c68aa0089d04d5 Mon Sep 17 00:00:00 2001 From: ell <77150506+ellraiser@users.noreply.github.com> Date: Mon, 9 Oct 2023 22:32:41 +0100 Subject: [PATCH] finish graphics module + HTML image comparison - added mostly all graphics draw tests - added a basic set of "expected" images (generated from successful tests) - HTML output now shows the expected vs actual generated images for each of the graphics tests applicable --- .github/workflows/main.yml | 33 +- .gitignore | 1 + testing/classes/TestMethod.lua | 38 ++- testing/classes/TestModule.lua | 2 +- testing/classes/TestSuite.lua | 2 - testing/main.lua | 3 + testing/output/actual/notes.txt | 2 + .../love.test.graphics.applyTransform-1.png | Bin 0 -> 89 bytes .../expected/love.test.graphics.arc-1.png | Bin 0 -> 245 bytes .../expected/love.test.graphics.arc-2.png | Bin 0 -> 204 bytes .../expected/love.test.graphics.arc-3.png | Bin 0 -> 223 bytes .../expected/love.test.graphics.circle-1.png | Bin 0 -> 212 bytes .../expected/love.test.graphics.clear-1.png | Bin 0 -> 84 bytes .../expected/love.test.graphics.draw-1.png | Bin 0 -> 221 bytes .../love.test.graphics.drawLayer-1.png | Bin 0 -> 386 bytes .../expected/love.test.graphics.ellipse-1.png | Bin 0 -> 185 bytes .../love.test.graphics.intersectScissor-1.png | Bin 0 -> 91 bytes .../expected/love.test.graphics.line-1.png | Bin 0 -> 139 bytes .../expected/love.test.graphics.origin-1.png | Bin 0 -> 90 bytes .../expected/love.test.graphics.points-1.png | Bin 0 -> 111 bytes .../expected/love.test.graphics.polygon-1.png | Bin 0 -> 154 bytes .../expected/love.test.graphics.pop-1.png | Bin 0 -> 90 bytes .../expected/love.test.graphics.print-1.png | Bin 0 -> 154 bytes .../expected/love.test.graphics.printf-1.png | Bin 0 -> 196 bytes .../expected/love.test.graphics.push-1.png | Bin 0 -> 91 bytes .../love.test.graphics.rectangle-1.png | Bin 0 -> 92 bytes .../love.test.graphics.rectangle-2.png | Bin 0 -> 103 bytes .../love.test.graphics.replaceTransform-1.png | Bin 0 -> 89 bytes .../expected/love.test.graphics.rotate-1.png | Bin 0 -> 91 bytes .../love.test.graphics.setBlendMode-1.png | Bin 0 -> 123 bytes .../love.test.graphics.setCanvas-1.png | Bin 0 -> 84 bytes .../love.test.graphics.setColor-1.png | Bin 0 -> 128 bytes .../love.test.graphics.setColorMask-1.png | Bin 0 -> 99 bytes .../expected/love.test.graphics.setFont-1.png | Bin 0 -> 106 bytes .../love.test.graphics.setLineJoin-1.png | Bin 0 -> 122 bytes .../love.test.graphics.setLineStyle-1.png | Bin 0 -> 102 bytes .../love.test.graphics.setLineWidth-1.png | Bin 0 -> 118 bytes .../love.test.graphics.setScissor-1.png | Bin 0 -> 89 bytes .../love.test.graphics.setShader-1.png | Bin 0 -> 84 bytes .../love.test.graphics.setStencilTest-1.png | Bin 0 -> 107 bytes .../love.test.graphics.setWireframe-1.png | Bin 0 -> 128 bytes .../expected/love.test.graphics.shear-1.png | Bin 0 -> 98 bytes .../expected/love.test.graphics.shear-2.png | Bin 0 -> 101 bytes .../love.test.graphics.translate-1.png | Bin 0 -> 93 bytes testing/output/expected/notes.txt | 2 + testing/output/{readme.md => notes.txt} | 0 testing/resources/loveinv.png | Bin 0 -> 680 bytes testing/tests/graphics.lua | 310 +++++++++++++++++- testing/todo.md | 5 +- 49 files changed, 366 insertions(+), 32 deletions(-) create mode 100644 testing/output/actual/notes.txt create mode 100644 testing/output/expected/love.test.graphics.applyTransform-1.png create mode 100644 testing/output/expected/love.test.graphics.arc-1.png create mode 100644 testing/output/expected/love.test.graphics.arc-2.png create mode 100644 testing/output/expected/love.test.graphics.arc-3.png create mode 100644 testing/output/expected/love.test.graphics.circle-1.png create mode 100644 testing/output/expected/love.test.graphics.clear-1.png create mode 100644 testing/output/expected/love.test.graphics.draw-1.png create mode 100644 testing/output/expected/love.test.graphics.drawLayer-1.png create mode 100644 testing/output/expected/love.test.graphics.ellipse-1.png create mode 100644 testing/output/expected/love.test.graphics.intersectScissor-1.png create mode 100644 testing/output/expected/love.test.graphics.line-1.png create mode 100644 testing/output/expected/love.test.graphics.origin-1.png create mode 100644 testing/output/expected/love.test.graphics.points-1.png create mode 100644 testing/output/expected/love.test.graphics.polygon-1.png create mode 100644 testing/output/expected/love.test.graphics.pop-1.png create mode 100644 testing/output/expected/love.test.graphics.print-1.png create mode 100644 testing/output/expected/love.test.graphics.printf-1.png create mode 100644 testing/output/expected/love.test.graphics.push-1.png create mode 100644 testing/output/expected/love.test.graphics.rectangle-1.png create mode 100644 testing/output/expected/love.test.graphics.rectangle-2.png create mode 100644 testing/output/expected/love.test.graphics.replaceTransform-1.png create mode 100644 testing/output/expected/love.test.graphics.rotate-1.png create mode 100644 testing/output/expected/love.test.graphics.setBlendMode-1.png create mode 100644 testing/output/expected/love.test.graphics.setCanvas-1.png create mode 100644 testing/output/expected/love.test.graphics.setColor-1.png create mode 100644 testing/output/expected/love.test.graphics.setColorMask-1.png create mode 100644 testing/output/expected/love.test.graphics.setFont-1.png create mode 100644 testing/output/expected/love.test.graphics.setLineJoin-1.png create mode 100644 testing/output/expected/love.test.graphics.setLineStyle-1.png create mode 100644 testing/output/expected/love.test.graphics.setLineWidth-1.png create mode 100644 testing/output/expected/love.test.graphics.setScissor-1.png create mode 100644 testing/output/expected/love.test.graphics.setShader-1.png create mode 100644 testing/output/expected/love.test.graphics.setStencilTest-1.png create mode 100644 testing/output/expected/love.test.graphics.setWireframe-1.png create mode 100644 testing/output/expected/love.test.graphics.shear-1.png create mode 100644 testing/output/expected/love.test.graphics.shear-2.png create mode 100644 testing/output/expected/love.test.graphics.translate-1.png create mode 100644 testing/output/expected/notes.txt rename testing/output/{readme.md => notes.txt} (100%) create mode 100644 testing/resources/loveinv.png diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7b0801aab..5229bdaf8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -4,6 +4,7 @@ on: [push, pull_request] jobs: linux-os: runs-on: ubuntu-20.04 + timeout-minutes: 60 steps: - name: Update APT run: sudo apt-get update @@ -50,9 +51,12 @@ jobs: name: love-x86_64-AppImage-debug path: love-${{ github.sha }}.AppImage-debug.tar.gz - name: Make Runnable - run: chmod a+x love-${{ github.sha }}.AppImage + run: | + chmod a+x love-${{ github.sha }}.AppImage + echo "ready to run" + ls - name: Run All Tests - run: xvfb-run ./love-${{ github.sha }}.AppImage testing + run: xvfb-run ./love-${{ github.sha }}.AppImage ./testing/main.lua - name: Love Test Report uses: ellraiser/love-test-report@main with: @@ -61,6 +65,7 @@ jobs: path: testing/output/lovetest_runAllTests.md windows-os: runs-on: windows-latest + timeout-minutes: 60 strategy: matrix: platform: [Win32, x64, ARM64] @@ -214,9 +219,21 @@ jobs: uses: actions/upload-artifact@v3 with: name: love-windows-${{ steps.vars.outputs.arch }}${{ steps.vars.outputs.compatname }}-dbg - path: pdb/Release/*.pdb + path: pdb/Release/*.pdb + - name: Install Scream + shell: powershell + run: | + Start-Service audio* + Invoke-WebRequest https://github.com/duncanthrax/scream/releases/download/3.6/Scream3.6.zip -OutFile C:\Scream3.6.zip + Extract-7Zip -Path C:\Scream3.6.zip -DestinationPath C:\Scream + $cert = (Get-AuthenticodeSignature C:\Scream\Install\driver\Scream.sys).SignerCertificate + $store = [System.Security.Cryptography.X509Certificates.X509Store]::new("TrustedPublisher", "LocalMachine") + $store.Open("ReadWrite") + $store.Add($cert) + $store.Close() + cd C:\Scream\Install\driver + C:\Scream\Install\helpers\devcon install Scream.inf *Scream - name: Install Mesa - if: steps.vars.outputs.arch != 'ARM64' run: | curl -L --output mesa.7z --url https://github.com/pal1000/mesa-dist-win/releases/download/23.2.1/mesa3d-23.2.1-release-msvc.7z 7z x mesa.7z -o* @@ -226,7 +243,9 @@ jobs: run: cmake --build build --config Release --target install - name: Run All Tests if: steps.vars.outputs.arch != 'ARM64' - run: powershell.exe install/lovec.exe testing + run: | + dir + powershell.exe ./install/lovec.exe ./testing/main.lua - name: Love Test Report if: steps.vars.outputs.arch != 'ARM64' uses: ellraiser/love-test-report@main @@ -236,6 +255,7 @@ jobs: path: testing/output/lovetest_runAllTests.md macOS: runs-on: macos-latest + timeout-minutes: 60 steps: - name: Checkout uses: actions/checkout@v3 @@ -263,7 +283,7 @@ jobs: name: love-macos path: love-macos.zip - name: Run All Tests - run: love-macos/love.app/Contents/MacOS/love testing + run: love-macos/love.app/Contents/MacOS/love testing/main.lua - name: Love Test Report uses: ellraiser/love-test-report@main with: @@ -272,6 +292,7 @@ jobs: path: testing/output/lovetest_runAllTests.md iOS-Simulator: runs-on: macos-latest + timeout-minutes: 60 steps: - name: Checkout uses: actions/checkout@v3 diff --git a/.gitignore b/.gitignore index f84038cd7..3f5288d45 100644 --- a/.gitignore +++ b/.gitignore @@ -72,3 +72,4 @@ stamp-h1 /testing/output/*.xml /testing/output/*.html /testing/output/*.md +/testing/output/actual/*.png diff --git a/testing/classes/TestMethod.lua b/testing/classes/TestMethod.lua index 9b355a6bb..ad3a742e6 100644 --- a/testing/classes/TestMethod.lua +++ b/testing/classes/TestMethod.lua @@ -33,9 +33,13 @@ TestMethod = { blue = {0, 0, 1, 1}, bluefade = {0, 0, 1, 0.5}, yellow = {1, 1, 0, 1}, + pink = {1, 0, 1, 1}, black = {0, 0, 0, 1}, - white = {1, 1, 1, 1} + white = {1, 1, 1, 1}, + lovepink = {214/255, 86/255, 151/255, 1}, + loveblue = {83/255, 168/255, 220/255, 1} }, + imgs = 1, delay = 0, delayed = false } @@ -82,6 +86,10 @@ TestMethod = { tg = math.floor((tg*10)+0.5)/10 tb = math.floor((tb*10)+0.5)/10 ta = math.floor((ta*10)+0.5)/10 + col[1] = math.floor((col[1]*10)+0.5)/10 + col[2] = math.floor((col[2]*10)+0.5)/10 + col[3] = math.floor((col[3]*10)+0.5)/10 + col[4] = math.floor((col[4]*10)+0.5)/10 -- @TODO add some sort pixel tolerance to the coords self:assertEquals(col[1], tr, 'check pixel r for ' .. i .. ' at ' .. compare_id .. '(' .. label .. ')') self:assertEquals(col[2], tg, 'check pixel g for ' .. i .. ' at ' .. compare_id .. '(' .. label .. ')') @@ -227,6 +235,14 @@ TestMethod = { end, + exportImg = function(self, imgdata) + local path = 'tempoutput/actual/love.test.graphics.' .. + self.method .. '-' .. tostring(self.imgs) .. '.png' + imgdata:encode('png', path) + self.imgs = self.imgs + 1 + end, + + -- @method - TestMethod:skipTest() -- @desc - used to mark this test as skipped for a specific reason -- @param {string} reason - reason why method is being skipped @@ -356,11 +372,21 @@ TestMethod = { -- unused currently, adds a preview image for certain graphics methods to the output local preview = '' - -- if self.testmodule.module == 'graphics' then - -- local filename = 'love_test_graphics_rectangle' - -- preview = '

Expected

Actual

Expected

Actual

Expected

Actual

Expected

Actual