Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2919038
shell.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
shell.js
View Options
import
{
test
,
summary
}
from
'./helpers.js'
;
import
{
$
}
from
'ant:shell'
;
console
.
log
(
'Shell Tests\n'
);
const
result
=
$
`echo hello`
;
test
(
'shell returns object'
,
typeof
result
,
'object'
);
test
(
'shell has exitCode'
,
typeof
result
.
exitCode
,
'number'
);
test
(
'shell exitCode success'
,
result
.
exitCode
,
0
);
test
(
'shell has text method'
,
typeof
result
.
text
,
'function'
);
test
(
'shell has lines method'
,
typeof
result
.
lines
,
'function'
);
test
(
'shell text returns string'
,
typeof
result
.
text
(),
'string'
);
test
(
'shell text content'
,
result
.
text
(),
'hello'
);
const
lines
=
result
.
lines
();
test
(
'shell lines returns array'
,
Array
.
isArray
(
lines
),
true
);
test
(
'shell lines content'
,
lines
[
0
],
'hello'
);
const
multiResult
=
$
`printf "line1\nline2\nline3"`
;
const
multiLines
=
multiResult
.
lines
();
test
(
'shell multi-line count'
,
multiLines
.
length
,
3
);
test
(
'shell multi-line first'
,
multiLines
[
0
],
'line1'
);
test
(
'shell multi-line last'
,
multiLines
[
2
],
'line3'
);
const
name
=
'world'
;
const
interpResult
=
$
`echo hello
${
name
}
`
;
test
(
'shell interpolation'
,
interpResult
.
text
(),
'hello world'
);
const
failResult
=
$
`exit 1`
;
test
(
'shell exit code failure'
,
failResult
.
exitCode
,
1
);
const
strResult
=
$
(
'echo string arg'
);
test
(
'shell string arg'
,
strResult
.
text
(),
'string arg'
);
summary
();
File Metadata
Details
Attached
Mime Type
application/javascript
Expires
Fri, Mar 27, 2:32 AM (2 d)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
512589
Default Alt Text
shell.js (1 KB)
Attached To
Mode
rANT Ant
Attached
Detach File
Event Timeline
Log In to Comment