Skip to content

Commit 810208d

Browse files
committed
ci: Run tests on Windows
1 parent 0bc2e3c commit 810208d

6 files changed

Lines changed: 44 additions & 21 deletions

File tree

.github/workflows/test.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,26 @@ jobs:
1313
- run: npx lj ui-test test/index.html
1414
- uses: coverallsapp/github-action@v2
1515
name: Upload to coveralls.io
16+
continue-on-error: true
1617
with:
1718
github-token: ${{ github.token }}
19+
Test:
20+
strategy:
21+
matrix:
22+
include:
23+
- { node: 20, os: windows-2022, arch: x86 }
24+
- { node: 22, os: macos-latest, arch: arm64 }
25+
runs-on: ${{ matrix.os }}
26+
name: Node ${{matrix.node}} (${{matrix.os}} ${{matrix.arch}})
27+
steps:
28+
- run: git config --global core.autocrlf false
29+
- uses: actions/checkout@v5
30+
- uses: actions/setup-node@v5
31+
with:
32+
node-version: ${{ matrix.node }}
33+
architecture: ${{ matrix.arch }}
34+
- run: npm install --no-audit && npm install -g uglify-js
35+
- run: npm test
1836
Analyze:
1937
uses: litejs/.github/.github/workflows/analyze.yml@main
2038
Release:

index.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,19 +85,23 @@ function isObj(obj) {
8585
return !!obj && obj.constructor === Object
8686
}
8787

88+
function fwd(s) {
89+
return s.replace(/\\/g, "/")
90+
}
91+
8892
function ls() {
8993
var key, dirRe, outRe, tmp, tmp2
9094
, arr = flat(arguments)
9195
, i = arr.length
9296
, out = []
9397
, paths = {}
94-
, reEscRe = /[*.+^=:${}()|\/\\]/g
98+
, reEscRe = /[*.+^=:${}()|\/]/g
9599
, opts = { absolute: false, cwd: process.cwd(), dir: true, dot: false, file: true, root: "", stat: false }
96100
for (; i > 0; ) {
97101
key = arr[--i]
98102
if (isObj(key)) Object.assign(opts, key)
99103
else if (typeof key === "string") {
100-
tmp = path.resolve(opts.cwd, tmp2 = key.replace(/[^\/]*\*.*/, ""))
104+
tmp = fwd(path.resolve(opts.cwd, tmp2 = key.replace(/[^\/]*\*.*/, "")))
101105
tmp = paths[tmp] || (paths[tmp] = [])
102106
if (key !== tmp2) tmp.push(key.slice(tmp2.length))
103107
}
@@ -118,14 +122,14 @@ function ls() {
118122
var stat = fs.statSync(name)
119123
if (outRe.test(name)) {
120124
if (stat.isDirectory() ? opts.dir : opts.file) out.push(
121-
opts.stat ? Object.assign(stat, { name: opts.absolute ? name : opts.root + path.relative(opts.cwd, name) }) :
125+
opts.stat ? Object.assign(stat, { name: opts.absolute ? name : opts.root + fwd(path.relative(opts.cwd, name)) }) :
122126
opts.absolute ? name :
123-
opts.root + path.relative(opts.cwd, name)
127+
opts.root + fwd(path.relative(opts.cwd, name))
124128
)
125129
}
126130
if (stat.isDirectory() && dirRe.test(name)) {
127131
fs.readdirSync(name).forEach(function(file) {
128-
scan(path.resolve(name, file))
132+
scan(fwd(path.resolve(name, file)))
129133
})
130134
}
131135
} catch(e) {}

lib/build.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -392,10 +392,11 @@ function html(opts, next) {
392392
}
393393

394394
function jsMin(opts) {
395-
var cmd = (jsMinCmd || [
396-
"uglifyjs --warn --ie8 -c 'evaluate=false,passes=2,properties=false'",
397-
"-m eval --comments '/^\\s*[@!]/'",
398-
"--beautify 'beautify=false,semicolons=false,keep_quoted_props=true'"
395+
var q = process.platform === "win32" ? "\"" : "'"
396+
, cmd = (jsMinCmd || [
397+
"uglifyjs --warn --ie8 -c " + q + "evaluate=false,passes=2,properties=false" + q,
398+
"-m eval --comments " + q + "/^\\s*[@!]/" + q,
399+
"--beautify " + q + "beautify=false,semicolons=false,keep_quoted_props=true" + q
399400
].join(" ")) + (opts.files ? " " + opts.files.join(" ") : jsMinCmd ? "" : " --")
400401
return child.execSync(cmd, opts).toString("utf8").replace(/\\x0B/g, "\\v")
401402
}

snapshot.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@ var cli = require(".")
33
, child = require("child_process")
44
, fs = require("fs")
55
, path = require("path")
6-
, relPathRe = /[^(]+(?=:\d+:\d+\))|^\/[\w/.]+(?=:\d)/gm
7-
, relPathFn = path.relative.bind(path, process.cwd())
6+
, relPathRe = /[^(]+(?=:\d+:\d+\))|^(?:\/|[A-Za-z]:\\)[\w/.\\-]+(?=:\d)/gm
7+
, cwd = process.cwd()
8+
, relPathFn = function(p) { return path.relative(cwd, p).replace(/\\/g, "/") }
89
, seen = {}
910

1011
/* globals describe */
1112

1213
function normalize(str) {
13-
return str.replace(relPathRe, relPathFn).replace(/at \w+\.<anonymous>/g, "at <anonymous>")
14+
return str.replace(/\r\n/g, "\n").replace(relPathRe, relPathFn).replace(/at \w+\.<anonymous>/g, "at <anonymous>")
1415
}
1516

1617
describe.assert.cmdSnapshot = function(cmd, file, opts) {

test/build.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ describe("build", function() {
4040
return initialFiles.indexOf(file) < 0
4141
})
4242
assert.planned = initialFiles.length + createdFiles.length + 2
43-
assert.cmdSnapshot("cd " + temp + ";find .|sort", prefix + "ls")
43+
assert.matchSnapshot(prefix + "ls", ".\n" + cli.ls(temp + "**/*").map(function(f) { return "./" + f.slice(temp.length) }).sort().join("\n") + "\n")
4444
assert.matchSnapshot(temp + outDir + "index.html", 0, prefix + "index.html")
4545
initialFiles.forEach(function(file) {
4646
file = file.replace("index.html", "dev.html")

test/tools.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ describe("tools", function() {
3636
assert.end()
3737
})
3838

39-
it ("should list files: {0}", [
39+
if (process.platform === "linux") it ("should list files: {0}", [
4040
"test/index.js",
4141
"*.js",
4242
"test/data/**/*",
@@ -54,21 +54,20 @@ describe("tools", function() {
5454
cli.mkdirp(".github/.dot")
5555
cli.cp("package.json", ".github/.dot/p.json")
5656
cli.cp(".github/.dot", ".github/.dot2")
57-
assert.equal(
57+
if (process.platform === "linux") assert.equal(
5858
cli.ls(".*/.d*", null, ".github").join(" "),
5959
child.execSync("bash -c 'shopt -s globstar;echo .github .*/.d*'").toString("utf8").trim()
6060
)
6161
// Assert options
6262
assert.equal(cli.ls(".github/*", { dir: false }).join(" "), ".github/jshint.json .github/litejs.json")
6363
assert.equal(cli.ls("*", { cwd: ".github", dir: false }).join(" "), "jshint.json litejs.json")
64-
assert.own(cli.ls("*", { cwd: ".github", stat: true }).map(s=>({size: s.size, name: s.name})), [
65-
{ size: 232, name: "jshint.json" },
66-
{ size: 268, name: "litejs.json" },
67-
{ size: 4096, name: "workflows" }
68-
])
64+
var stats = cli.ls("*", { cwd: ".github", stat: true }).map(s=>({size: s.size, name: s.name}))
65+
assert.equal(stats.length, 3)
66+
assert.equal(stats[0].size, 232)
67+
assert.equal(stats[2].name, "workflows")
6968
assert.equal(cli.ls(".github/*", { file: false }).join(" "), ".github/workflows")
7069
assert.equal(cli.ls(".github/*", { file: false, root: "/www/" }).join(" "), "/www/.github/workflows")
71-
assert.equal(cli.ls(".github/*", { file: false, absolute: true }).join(" "), path.join(process.cwd(), ".github/workflows"))
70+
assert.equal(cli.ls(".github/*", { file: false, absolute: true }).join(" "), path.join(process.cwd(), ".github/workflows").replace(/\\/g, "/"))
7271
assert.equal(cli.ls(".github/*", { dot: true }).join(" "), ".github/.dot .github/.dot2 .github/jshint.json .github/litejs.json .github/workflows")
7372
cli.rmrf(".github/.dot")
7473
cli.rmrf(".github/.dot2")

0 commit comments

Comments
 (0)