From c7d4eeb46481a51d7ad9e142dee7e804f37bec36 Mon Sep 17 00:00:00 2001 From: Hu Song Date: Fri, 11 Aug 2023 15:18:53 +0800 Subject: [PATCH] Fix ci test (#1677) * ci: test --- .github/workflows/ci.yml | 2 +- .../extensions/KHR_draco_mesh_compression.ts | 3 +- tests/index.ts | 2 +- tests/src/core/AssetPromise.test.ts | 1 - tests/src/core/Camera.test.ts | 30 ++++++++----------- tests/src/core/material/Material.test.ts | 5 ++-- 6 files changed, 19 insertions(+), 24 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7d63245aa..389ab6be8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -53,7 +53,7 @@ jobs: - run: npm run build codecov: - runs-on: ubuntu-latest + runs-on: macos-latest steps: - uses: actions/checkout@v3 diff --git a/packages/loader/src/gltf/extensions/KHR_draco_mesh_compression.ts b/packages/loader/src/gltf/extensions/KHR_draco_mesh_compression.ts index 42cb34595..ebac2d45e 100644 --- a/packages/loader/src/gltf/extensions/KHR_draco_mesh_compression.ts +++ b/packages/loader/src/gltf/extensions/KHR_draco_mesh_compression.ts @@ -199,9 +199,8 @@ class KHR_draco_mesh_compression extends GLTFExtensionParser { } else { mesh.addSubMesh(0, vertexCount, mode); } - // BlendShapes - targets && GLTFMeshParser._createBlendShape(mesh, null, gltfMesh,accessors, targets, getBlendShapeData); + targets && GLTFMeshParser._createBlendShape(mesh, null, gltfMesh, accessors, targets, getBlendShapeData); mesh.uploadData(!keepMeshData); return Promise.resolve(mesh); diff --git a/tests/index.ts b/tests/index.ts index 63420318a..2a757c812 100644 --- a/tests/index.ts +++ b/tests/index.ts @@ -8,7 +8,7 @@ function searchTests(root: string) { if (stat.isFile() && filePath.endsWith(".test.ts")) { require(filePath); } else if (stat.isDirectory()) { - describe(file, () => { + describe(file, function () { searchTests(filePath); }).timeout(5000); } diff --git a/tests/src/core/AssetPromise.test.ts b/tests/src/core/AssetPromise.test.ts index 7eb335b81..b98a2445d 100644 --- a/tests/src/core/AssetPromise.test.ts +++ b/tests/src/core/AssetPromise.test.ts @@ -96,7 +96,6 @@ describe("Asset Promise test", function () { let expectProgress = 0; assetPromise.onProgress((progress) => { expectProgress += 0.1; - console.log("set progress", expectProgress, progress); expect(progress).to.approximately(expectProgress, 0.0001); }); diff --git a/tests/src/core/Camera.test.ts b/tests/src/core/Camera.test.ts index d1df43988..4a619a488 100644 --- a/tests/src/core/Camera.test.ts +++ b/tests/src/core/Camera.test.ts @@ -1,18 +1,16 @@ import { Matrix, Ray, Vector2, Vector3, Vector4 } from "@galacean/engine-math"; -import { WebGLEngine } from "@galacean/engine-rhi-webgl"; +import { WebCanvas, WebGLEngine, WebGLGraphicDevice } from "@galacean/engine-rhi-webgl"; import { Camera, CameraClearFlags, Entity, Layer } from "@galacean/engine-core"; import { expect } from "chai"; -const canvasDOM = document.createElement("canvas"); -canvasDOM.width = 1024; -canvasDOM.height = 1024; - describe("camera test", function () { + const canvasDOM = new OffscreenCanvas(256, 256); let node: Entity; let camera: Camera; let identityMatrix: Matrix; - before(async () => { + before(async function () { + this.timeout(10000); const engine = await WebGLEngine.create({ canvas: canvasDOM }); node = engine.sceneManager.activeScene.createRootEntity(); camera = node.addComponent(Camera); @@ -30,7 +28,7 @@ describe("camera test", function () { // Test set renderTarget values camera.renderTarget = null; expect(camera.renderTarget).to.eq(null); - + // Test that _renderPipeline is not undefined expect(camera["_renderPipeline"]).not.to.be.undefined; }); @@ -67,7 +65,7 @@ describe("camera test", function () { // Test viewport const originViewPort = new Vector4(0, 0, 1, 1); - const expectedViewPort = new Vector4(0, 1, 0, 1); + const expectedViewPort = new Vector4(0, 1, 0, 1); expect(camera.viewport).to.deep.eq(originViewPort); camera.viewport = expectedViewPort; expect(camera.viewport).to.deep.eq(expectedViewPort); @@ -219,13 +217,7 @@ describe("camera test", function () { // Test perspective projection matrix camera.aspectRatio = 2; camera.fieldOfView = 60; - Matrix.perspective( - 60 * Math.PI / 180, - 2, - camera.nearClipPlane, - camera.farClipPlane, - camera.viewMatrix - ); + Matrix.perspective((60 * Math.PI) / 180, 2, camera.nearClipPlane, camera.farClipPlane, camera.viewMatrix); expect(camera.projectionMatrix).to.deep.eq(camera.viewMatrix); // Test orthographic projection matrix @@ -255,11 +247,15 @@ describe("camera test", function () { expect(projectionMatrix[11]).to.eq(-viewMatrix[15]); expect(projectionMatrix[12]).to.eq(-viewMatrix[12]); expect(projectionMatrix[13]).to.eq(-viewMatrix[13]); - expect(projectionMatrix[14] - projectionMatrix[0]).to.be.closeTo(viewMatrix[14], 0.1, "Result should match expected value"); + expect(projectionMatrix[14] - projectionMatrix[0]).to.be.closeTo( + viewMatrix[14], + 0.1, + "Result should match expected value" + ); expect(projectionMatrix[15]).to.eq(viewMatrix[11]); // Test reset projection matrix camera.projectionMatrix = camera.viewMatrix; expect(camera.projectionMatrix).to.deep.eq(camera.viewMatrix); }); -}); \ No newline at end of file +}); diff --git a/tests/src/core/material/Material.test.ts b/tests/src/core/material/Material.test.ts index 6b521c059..7b2fcc36b 100644 --- a/tests/src/core/material/Material.test.ts +++ b/tests/src/core/material/Material.test.ts @@ -3,9 +3,10 @@ import { Color, Matrix, Vector2, Vector3, Vector4 } from "@galacean/engine-math" import { WebGLEngine } from "@galacean/engine-rhi-webgl"; import { expect } from "chai"; -describe("Material", () => { +describe("Material", () => { let engine: WebGLEngine; - before(async () => { + before(async function () { + this.timeout(10000); engine = await WebGLEngine.create({ canvas: document.createElement("canvas") }); });