feat: test case for wcc raw

This commit is contained in:
msojocs 2023-08-31 09:13:40 +08:00
parent 7719cf14f1
commit 1044f2d57c
2 changed files with 19 additions and 18 deletions

View File

@ -1,8 +1,9 @@
const assert = require("assert");
const node = require("../../runner/node"); import assert from 'assert';
const wine = require("../../runner/wine"); import path from 'path';
const path = require("path"); import node from '../../../runner/node'
const fs = require("fs"); import wine from '../../../runner/wine'
import * as fs from 'fs'
describe("wcc - raw", function () { describe("wcc - raw", function () {
describe("Raw: node output should equal with wine", function () { describe("Raw: node output should equal with wine", function () {
@ -14,7 +15,7 @@ describe("wcc - raw", function () {
it("初次加载1", async function () { it("初次加载1", async function () {
const projectPath = path.resolve( const projectPath = path.resolve(
__dirname, __dirname,
"../../examples/miniprogram-demo/miniprogram" "/mnt/d/Work/WeChatProjects/miniprogram-demo/miniprogram"
); );
const args = [ const args = [
"-d", "-d",
@ -41,11 +42,11 @@ describe("wcc - raw", function () {
"-gn", "-gn",
"$gwx", "$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 n = await node.wcc(args, projectPath);
const storagePath = path.resolve( const storagePath = path.resolve(
__dirname, __dirname,
`miniprogram-demo/${this.test.title}` `miniprogram-demo/${this.test?.title}`
); );
try { try {
fs.mkdirSync(storagePath, { recursive: true }); fs.mkdirSync(storagePath, { recursive: true });
@ -58,7 +59,7 @@ describe("wcc - raw", function () {
it("初次加载2", async function () { it("初次加载2", async function () {
const projectPath = path.resolve( const projectPath = path.resolve(
__dirname, __dirname,
"../../examples/miniprogram-demo/miniprogram/" "/mnt/d/Work/WeChatProjects/miniprogram-demo/miniprogram"
); );
const args = [ const args = [
"-d", "-d",
@ -92,11 +93,11 @@ describe("wcc - raw", function () {
"-gn", "-gn",
"$7061636b616765536b796c696e652f", "$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 n = await node.wcc(args, projectPath);
const storagePath = path.resolve( const storagePath = path.resolve(
__dirname, __dirname,
`miniprogram-demo/${this.test.title}` `miniprogram-demo/${this.test?.title}`
); );
try { try {
fs.mkdirSync(storagePath, { recursive: true }); fs.mkdirSync(storagePath, { recursive: true });
@ -108,7 +109,7 @@ describe("wcc - raw", function () {
it("组件 - skyline - 自定义路由", async function () { it("组件 - skyline - 自定义路由", async function () {
const projectPath = path.resolve( const projectPath = path.resolve(
__dirname, __dirname,
"../../examples/miniprogram-demo/miniprogram/" "/mnt/d/Work/WeChatProjects/miniprogram-demo/miniprogram"
); );
const args = [ const args = [
"-d", "-d",
@ -135,11 +136,11 @@ describe("wcc - raw", function () {
"-gn", "-gn",
"$gwx", "$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 n = await node.wcc(args, projectPath);
const storagePath = path.resolve( const storagePath = path.resolve(
__dirname, __dirname,
`miniprogram-demo/${this.test.title}` `miniprogram-demo/${this.test?.title}`
); );
try { try {
fs.mkdirSync(storagePath, { recursive: true }); fs.mkdirSync(storagePath, { recursive: true });
@ -151,7 +152,7 @@ describe("wcc - raw", function () {
it("组件 - skyline - 自定义路由 -2", async function () { it("组件 - skyline - 自定义路由 -2", async function () {
const projectPath = path.resolve( const projectPath = path.resolve(
__dirname, __dirname,
"../../examples/miniprogram-demo/miniprogram/" "/mnt/d/Work/WeChatProjects/miniprogram-demo/miniprogram"
); );
const args = [ const args = [
"-d", "-d",
@ -185,11 +186,11 @@ describe("wcc - raw", function () {
"-gn", "-gn",
"$7061636b616765536b796c696e652f", "$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 n = await node.wcc(args, projectPath);
const storagePath = path.resolve( const storagePath = path.resolve(
__dirname, __dirname,
`miniprogram-demo/${this.test.title}` `miniprogram-demo/${this.test?.title}`
); );
try { try {
fs.mkdirSync(storagePath, { recursive: true }); fs.mkdirSync(storagePath, { recursive: true });

View File

@ -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 # /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 # /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; # 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 /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 /mnt/d/Work/disassembly/wcc-exec/wcc/wcc.exe "--config-path" "d:/Work/$filename" > /root/github/wx-compiler/test/wcc_win.json