Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2920853
run.js
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
run.js
View Options
import
fs
from
'ant:fs'
;
import
path
from
'ant:path'
;
import
{
$
}
from
'ant:shell'
;
const
GREEN
=
'\x1b[32m'
;
const
RED
=
'\x1b[31m'
;
const
CYAN
=
'\x1b[36m'
;
const
PINK
=
'\x1b[35m'
;
const
BOLD
=
'\x1b[1m'
;
const
DIM
=
'\x1b[2m'
;
const
RESET
=
'\x1b[0m'
;
const
specDir
=
path
.
dirname
(
import
.
meta
.
url
.
replace
(
'file://'
,
''
));
const
files
=
fs
.
readdirSync
(
specDir
)
.
filter
(
f
=>
f
.
endsWith
(
'.js'
)
&&
f
!==
'run.js'
&&
f
!==
'helpers.js'
)
.
sort
();
let
totalPassed
=
0
;
let
totalFailed
=
0
;
let
filesPassed
=
0
;
let
filesFailed
=
0
;
console
.
log
(
`\n
${
BOLD
}${
CYAN
}
Running
${
files
.
length
}
spec files...
${
RESET
}
\n`
);
for
(
const
file
of
files
)
{
const
filePath
=
path
.
join
(
specDir
,
file
);
const
name
=
path
.
basename
(
file
,
'.js'
);
try
{
const
result
=
$
`./build/ant
${
filePath
}
`
;
const
output
=
result
.
text
();
console
.
log
(
output
);
const
passedMatch
=
output
.
match
(
/Passed:\s*(\d+)/
);
const
failedMatch
=
output
.
match
(
/Failed:\s*(\d+)/
);
if
(
passedMatch
)
totalPassed
+=
parseInt
(
passedMatch
[
1
],
10
);
if
(
failedMatch
)
totalFailed
+=
parseInt
(
failedMatch
[
1
],
10
);
if
(
result
.
exitCode
===
0
)
{
console
.
log
(
`
${
GREEN
}
✓
${
RESET
}
${
name
}
\n`
);
filesPassed
++
;
}
else
{
console
.
log
(
`
${
RED
}
✗
${
RESET
}
${
name
}
\n`
);
filesFailed
++
;
}
}
catch
(
e
)
{
console
.
log
(
`
${
RED
}
✗
${
RESET
}
${
name
}
${
DIM
}
(error)
${
RESET
}
\n`
);
filesFailed
++
;
}
}
console
.
log
(
`\n
${
BOLD
}
Results:
${
RESET
}
`
);
console
.
log
(
`
${
GREEN
}${
totalPassed
}
tests passed
${
RESET
}
`
);
console
.
log
(
`
${
RED
}${
totalFailed
}
tests failed
${
RESET
}
`
);
console
.
log
(
`
${
GREEN
}${
filesPassed
}
files passed
${
RESET
}
`
);
console
.
log
(
`
${
RED
}${
filesFailed
}
files failed
${
RESET
}
\n`
);
console
.
log
(
`
${
PINK
}
Welcome to ES6!
${
RESET
}
`
);
process
.
exit
(
totalFailed
>
0
?
1
:
0
);
File Metadata
Details
Attached
Mime Type
application/javascript
Expires
Fri, Mar 27, 7:18 AM (2 d)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
512626
Default Alt Text
run.js (1 KB)
Attached To
Mode
rANT Ant
Attached
Detach File
Event Timeline
Log In to Comment