Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
test
autotest-playwright-web-spd
Commits
bcf72d87
Commit
bcf72d87
authored
Sep 15, 2026
by
liguangyu06
Browse files
Decode Playwright UTF-8 logs as GBK on Windows Jenkins console.
parent
8deff6eb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Jenkinsfile
View file @
bcf72d87
...
...
@@ -44,7 +44,7 @@ def runCi() {
}
else
{
bat
'''
set PATH=C:\\Program Files\\nodejs;%PATH%
node scripts\\run-ci.mjs --suite=%SUITE% --shards=%SHARDS%
node scripts\\run-ci
-win
.mjs --suite=%SUITE% --shards=%SHARDS%
'''
}
}
...
...
scripts/run-ci-win.mjs
0 → 100644
View file @
bcf72d87
/**
* Windows Jenkins 控制台按 GBK 解码,Node/Playwright 日志是 UTF-8。
* 本入口把 run-ci 的 stdout/stderr 转成 GBK 再交给 Jenkins。
*/
import
{
spawn
}
from
'
node:child_process
'
;
import
{
existsSync
}
from
'
node:fs
'
;
import
path
from
'
node:path
'
;
import
{
fileURLToPath
}
from
'
node:url
'
;
const
ROOT
=
path
.
resolve
(
path
.
dirname
(
fileURLToPath
(
import
.
meta
.
url
)),
'
..
'
);
const
RUN_CI
=
path
.
join
(
ROOT
,
'
scripts/run-ci.mjs
'
);
const
ICONV_CANDIDATES
=
[
process
.
env
.
GIT_ICONV
,
'
C:
\\
Users
\\
Administrator
\\
AppData
\\
Local
\\
Programs
\\
Git
\\
usr
\\
bin
\\
iconv.exe
'
,
'
C:
\\
Program Files
\\
Git
\\
usr
\\
bin
\\
iconv.exe
'
,
'
C:
\\
Program Files (x86)
\\
Git
\\
usr
\\
bin
\\
iconv.exe
'
,
].
filter
(
Boolean
);
function
findIconv
()
{
return
ICONV_CANDIDATES
.
find
((
item
)
=>
existsSync
(
item
))
||
''
;
}
function
runInherited
()
{
const
child
=
spawn
(
process
.
execPath
,
[
RUN_CI
,
...
process
.
argv
.
slice
(
2
)],
{
cwd
:
ROOT
,
stdio
:
'
inherit
'
,
env
:
process
.
env
,
});
child
.
on
(
'
exit
'
,
(
code
)
=>
process
.
exit
(
code
??
1
));
child
.
on
(
'
error
'
,
(
err
)
=>
{
console
.
error
(
err
);
process
.
exit
(
1
);
});
}
function
pipeThroughIconv
(
readable
,
iconvPath
)
{
const
encodings
=
[
'
GBK//TRANSLIT
'
,
'
GBK//IGNORE
'
,
'
GBK
'
,
'
CP936
'
];
const
to
=
encodings
[
0
];
const
conv
=
spawn
(
iconvPath
,
[
'
-f
'
,
'
UTF-8
'
,
'
-t
'
,
to
],
{
stdio
:
[
'
pipe
'
,
'
inherit
'
,
'
inherit
'
],
});
readable
.
pipe
(
conv
.
stdin
);
return
conv
;
}
function
waitClose
(
child
)
{
return
new
Promise
((
resolve
)
=>
{
if
(
!
child
||
child
.
exitCode
!==
null
)
{
resolve
();
return
;
}
child
.
on
(
'
close
'
,
()
=>
resolve
());
});
}
const
onJenkinsWin
=
process
.
platform
===
'
win32
'
&&
Boolean
(
process
.
env
.
JENKINS_URL
);
const
iconvPath
=
findIconv
();
if
(
!
onJenkinsWin
||
!
iconvPath
)
{
runInherited
();
}
else
{
const
child
=
spawn
(
process
.
execPath
,
[
RUN_CI
,
...
process
.
argv
.
slice
(
2
)],
{
cwd
:
ROOT
,
stdio
:
[
'
inherit
'
,
'
pipe
'
,
'
pipe
'
],
env
:
process
.
env
,
});
const
outConv
=
pipeThroughIconv
(
child
.
stdout
,
iconvPath
);
const
errConv
=
pipeThroughIconv
(
child
.
stderr
,
iconvPath
);
child
.
on
(
'
error
'
,
(
err
)
=>
{
console
.
error
(
err
);
process
.
exit
(
1
);
});
child
.
on
(
'
exit
'
,
async
(
code
)
=>
{
await
Promise
.
all
([
waitClose
(
outConv
),
waitClose
(
errConv
)]);
process
.
exit
(
code
??
1
);
});
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment