From 1044f2d57cf3b8971c38fcf27224ae8b670ff520 Mon Sep 17 00:00:00 2001 From: msojocs Date: Thu, 31 Aug 2023 09:13:40 +0800 Subject: [PATCH] feat: test case for wcc raw --- .../spec/wcc/raw/{raw.test.js => raw.spec.ts} | 35 ++++++++++--------- test/wcc.sh | 2 +- 2 files changed, 19 insertions(+), 18 deletions(-) rename test/spec/wcc/raw/{raw.test.js => raw.spec.ts} (94%) diff --git a/test/spec/wcc/raw/raw.test.js b/test/spec/wcc/raw/raw.spec.ts similarity index 94% rename from test/spec/wcc/raw/raw.test.js rename to test/spec/wcc/raw/raw.spec.ts index 9702ebd..7a8f6d3 100644 --- a/test/spec/wcc/raw/raw.test.js +++ b/test/spec/wcc/raw/raw.spec.ts @@ -1,8 +1,9 @@ -const assert = require("assert"); -const node = require("../../runner/node"); -const wine = require("../../runner/wine"); -const path = require("path"); -const fs = require("fs"); + +import assert from 'assert'; +import path from 'path'; +import node from '../../../runner/node' +import wine from '../../../runner/wine' +import * as fs from 'fs' describe("wcc - raw", function () { describe("Raw: node output should equal with wine", function () { @@ -14,7 +15,7 @@ describe("wcc - raw", function () { it("初次加载1", async function () { const projectPath = path.resolve( __dirname, - "../../examples/miniprogram-demo/miniprogram" + "/mnt/d/Work/WeChatProjects/miniprogram-demo/miniprogram" ); const args = [ "-d", @@ -41,11 +42,11 @@ describe("wcc - raw", function () { "-gn", "$gwx", ]; - const w = (await wine.wcc(args, projectPath)).replaceAll("\r\n", "\n"); + const w = (await wine.wcc(args, projectPath)).replace(/\r\n/g, '\n') const n = await node.wcc(args, projectPath); const storagePath = path.resolve( __dirname, - `miniprogram-demo/${this.test.title}` + `miniprogram-demo/${this.test?.title}` ); try { fs.mkdirSync(storagePath, { recursive: true }); @@ -58,7 +59,7 @@ describe("wcc - raw", function () { it("初次加载2", async function () { const projectPath = path.resolve( __dirname, - "../../examples/miniprogram-demo/miniprogram/" + "/mnt/d/Work/WeChatProjects/miniprogram-demo/miniprogram" ); const args = [ "-d", @@ -92,11 +93,11 @@ describe("wcc - raw", function () { "-gn", "$7061636b616765536b796c696e652f", ]; - const w = (await wine.wcc(args, projectPath)).replaceAll("\r\n", "\n"); + const w = (await wine.wcc(args, projectPath)).replace(/\r\n/g, "\n"); const n = await node.wcc(args, projectPath); const storagePath = path.resolve( __dirname, - `miniprogram-demo/${this.test.title}` + `miniprogram-demo/${this.test?.title}` ); try { fs.mkdirSync(storagePath, { recursive: true }); @@ -108,7 +109,7 @@ describe("wcc - raw", function () { it("组件 - skyline - 自定义路由", async function () { const projectPath = path.resolve( __dirname, - "../../examples/miniprogram-demo/miniprogram/" + "/mnt/d/Work/WeChatProjects/miniprogram-demo/miniprogram" ); const args = [ "-d", @@ -135,11 +136,11 @@ describe("wcc - raw", function () { "-gn", "$gwx", ]; - const w = (await wine.wcc(args, projectPath)).replaceAll("\r\n", "\n"); + const w = (await wine.wcc(args, projectPath)).replace(/\r\n/g, "\n"); const n = await node.wcc(args, projectPath); const storagePath = path.resolve( __dirname, - `miniprogram-demo/${this.test.title}` + `miniprogram-demo/${this.test?.title}` ); try { fs.mkdirSync(storagePath, { recursive: true }); @@ -151,7 +152,7 @@ describe("wcc - raw", function () { it("组件 - skyline - 自定义路由 -2", async function () { const projectPath = path.resolve( __dirname, - "../../examples/miniprogram-demo/miniprogram/" + "/mnt/d/Work/WeChatProjects/miniprogram-demo/miniprogram" ); const args = [ "-d", @@ -185,11 +186,11 @@ describe("wcc - raw", function () { "-gn", "$7061636b616765536b796c696e652f", ]; - const w = (await wine.wcc(args, projectPath)).replaceAll("\r\n", "\n"); + const w = (await wine.wcc(args, projectPath)).replace(/\r\n/g, "\n"); const n = await node.wcc(args, projectPath); const storagePath = path.resolve( __dirname, - `miniprogram-demo/${this.test.title}` + `miniprogram-demo/${this.test?.title}` ); try { fs.mkdirSync(storagePath, { recursive: true }); diff --git a/test/wcc.sh b/test/wcc.sh index 21ef7b6..c3d1df9 100644 --- a/test/wcc.sh +++ b/test/wcc.sh @@ -11,6 +11,6 @@ cd /mnt/d/Work/WeChatProjects/miniprogram-1 # /root/github/wx-compiler/build/wcc "--config-path" "/mnt/d/Work/disassembly/wcc-exec/wcc/config/$cmd.txt" > /root/github/wx-compiler/test/wcc_linux.json # /mnt/d/Work/disassembly/wcc-exec/wcc/wcc.exe "--config-path" "d:/Work/disassembly/wcc-exec/wcc/config/$cmd.txt" > /root/github/wx-compiler/test/wcc_win.json # done; -filename="WeChatProjects/miniprogram-1/wcc/99a9bac3c05fc25dd070298212c4a7d3" +filename="WeChatProjects/miniprogram-1/wcc/2535335225445086ae78aa14d79fe1d5" /root/github/wx-compiler/build/wcc "--config-path" "/mnt/d/Work/$filename" > /root/github/wx-compiler/test/wcc_linux.json /mnt/d/Work/disassembly/wcc-exec/wcc/wcc.exe "--config-path" "d:/Work/$filename" > /root/github/wx-compiler/test/wcc_win.json