mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-11-28 19:55:53 +03:00
rewrite test.ls in terms of runner.ls:Urbit
no error handling implemented yet
This commit is contained in:
parent
7c8ddd4b0a
commit
b290eaefb1
@ -9,6 +9,8 @@
|
||||
"author": "~fyr",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"colors": "^1.1.2",
|
||||
"escape-string-regexp": "^1.0.5",
|
||||
"livescript": "^1.5.0",
|
||||
"once": "^1.4.0",
|
||||
"promise-streams": "^2.1.1",
|
||||
|
@ -1,4 +1,4 @@
|
||||
require! <[ stream-snitch ]>
|
||||
require! <[ stream-snitch colors escape-string-regexp ]>
|
||||
pty = require \pty.js
|
||||
|
||||
export class Urbit
|
||||
@ -6,10 +6,15 @@ export class Urbit
|
||||
@stdout = process.stdout # overridable
|
||||
@pty = pty.spawn \urbit args
|
||||
@pty.on \data ~> @stdout.write it # TODO pipe?
|
||||
console.log "FIXME Running Ubuntu 14.04, which causes a libtinfo version info warning. Should update to 16.04.\n"
|
||||
#
|
||||
@last-output = Date.now()
|
||||
@pty.on \data ~> @last-output = Date.now()
|
||||
#
|
||||
process.on \exit ~> @pty.write '\04' # send EOF to gracefully checkpoint
|
||||
#
|
||||
note: -> console.log "node:".blue, it
|
||||
warn: -> console.log "node:".red, it
|
||||
wait-silent: ~> # this feels hacky
|
||||
new Promise (resolve)~>
|
||||
a = set-interval ~>
|
||||
@ -19,8 +24,14 @@ export class Urbit
|
||||
, 200
|
||||
expect: (re)~>
|
||||
new Promise (resolve)~>
|
||||
#@listeners.push
|
||||
@pty.pipe (new stream-snitch re).once "match" resolve
|
||||
expect-error: -> @expect /\r\x1b\[K(\/~|ford: )/
|
||||
expect-error: -> @expect /\r\x1b\[K(\/~|ford: )/ #ALT if-error
|
||||
expect-immediate: (re)->
|
||||
Promise.race [
|
||||
@expect re
|
||||
@wait-silent!then -> throw Error "Expected #re during event"
|
||||
]
|
||||
#
|
||||
line: ->
|
||||
@pty.write it
|
||||
@ -28,7 +39,13 @@ export class Urbit
|
||||
@stdout.write "\n"
|
||||
@pty.write "\r"
|
||||
#
|
||||
expect-echo: (s)-> #ALT send-and-expect
|
||||
<~ @line s .then
|
||||
@expect-immediate new RegExp escape-string-regexp s
|
||||
#
|
||||
exit: (code)->
|
||||
@pty.on \exit -> process.exit code #REVIEW just return promise?
|
||||
# @pty.write "\03" # ^C running event
|
||||
@pty.write "\05\25" # ^E^U to clear prompt
|
||||
@pty.write "\04" # ^D to checkpoint
|
||||
# set-timeout # hard exit
|
||||
|
@ -1,56 +1,32 @@
|
||||
require! <[ stream-snitch once ]>
|
||||
pty = require \pty.js
|
||||
{Urbit} = require './runner.ls'
|
||||
|
||||
urbit =
|
||||
# TODO abort on failure
|
||||
pty.spawn 'urbit' <[-B urbit.pill -A .. -cFI zod zod]>
|
||||
.on \data -> process.stdout.write it
|
||||
|
||||
console.log "FIXME Running Ubuntu 14.04, which causes a libtinfo version info warning. Should update to 16.04.\n"
|
||||
|
||||
|
||||
urbit.on \exit (code)->
|
||||
console.log "\nnode: urbit exited with code #code\n"
|
||||
process.exit code
|
||||
|
||||
process.on \exit -> urbit.write '\04' # send EOF to gracefully checkpoint
|
||||
|
||||
exit-code = 0
|
||||
|
||||
|
||||
on-next = (re,cb)->
|
||||
urbit.pipe (new stream-snitch re).on \match once cb
|
||||
|
||||
on-next /\r\x1b\[K(\/~|ford: )/ ->
|
||||
console.log "\n\n---\nnode: detected error, exiting in ~s30\n---\n\n"
|
||||
exit-code := 1
|
||||
set-timeout (-> process.exit 1), 30000
|
||||
|
||||
<- on-next /dojo> /
|
||||
|
||||
urbit.write "%got-dojo\r"
|
||||
<- on-next /%got-dojo/
|
||||
|
||||
|
||||
urbit.write "|start %test\r:test [%cores /]\r"
|
||||
<- on-next /%cores-tested/
|
||||
|
||||
if exit-code
|
||||
process.exit exit-code
|
||||
|
||||
urbit.write "+test, =defer |, =seed `@uvI`(shaz %reproducible)\r"
|
||||
on-next /(FAILED|CRASHED)/ ->
|
||||
console.log "\n\n---\nnode: detected error\n---\n\n"
|
||||
exit-code := 2
|
||||
|
||||
urbit.write "%tested\r"
|
||||
<- on-next /%tested/
|
||||
|
||||
|
||||
if exit-code
|
||||
process.exit exit-code
|
||||
|
||||
console.log "\n\n---\nnode: STUB insert further tests here\n---\n\n"
|
||||
|
||||
urbit.write '\04'
|
||||
set-timeout (-> process.exit exit-code), 1000
|
||||
urbit = new Urbit <[-B urbit.pill -A .. -cFI zod zod]>
|
||||
Promise.resolve urbit
|
||||
.then (urb)->
|
||||
urb.note "Booting urbit"
|
||||
# TODO exit on ford stack trace
|
||||
<- urb.expect /dojo> / .then
|
||||
<- urb.expect-echo "%dojo-booted" .then
|
||||
urb
|
||||
.then (urb)->
|
||||
urb.note "Testing compilation"
|
||||
# TODO tally ford stack traces
|
||||
# urb.warn etc
|
||||
<- urb.line "|start %test" .then
|
||||
<- urb.line ":test [%cores /]" .then
|
||||
<- urb.expect-echo "%compilation-tested" .then
|
||||
#if tally => throw # a fit
|
||||
urb
|
||||
.then (urb)->
|
||||
urb.note "Running /===/tests"
|
||||
# TODO tally FAILED and CRASHED
|
||||
<- urb.line "+test, =defer |, =seed `@uvI`(shaz %reproducible)" .then
|
||||
<- urb.expect-echo "%ran-tests" .then
|
||||
#if tally => throw # a fit
|
||||
urb
|
||||
.then ->
|
||||
urbit.exit 0
|
||||
.catch (err)->
|
||||
<- urbit.wait-silent!then # assumptions?
|
||||
urbit.warn err
|
||||
urbit.exit 1
|
||||
|
Loading…
Reference in New Issue
Block a user