-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Port e2e tests to node #390
Conversation
let stderr = '' | ||
|
||
// return this function so the process can be killed | ||
const exit = () => new Promise((resolve, reject) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same issue we had with bash, doing subprocess.kill()
would not stop a background process.
For example:
13388 ~ 'node: npm test'
`- 9164 ~ 'node: ava'
`- 9488 ~ 'node: execa' <- this is what I get in the test, which does not want to die :(
`- 11808 ~ 'node: aragon ipfs'
`- 24548 ~ 'ipfs'
Even if we listen to the 'exit' event in the CLI:
process.on('exit', (code, signal) => {
console.log('parent said exit', code, signal)
ipfsProc.kill()
process.exit()
})
Most likely child.pid
returns a Group ID, and node cannot kill groups on windows: nodejs/node#3617
Solution: https://www.npmjs.com/package/ps-tree which returns the 2 children which we can kill. 🔪
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great solution 🎉
}) | ||
} | ||
|
||
test('should return the correct version', async t => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are some issues with nixt
:
- for some reason the callback style
.end()
function did not play nice withava
(could have been because of me), had to extend it to support promises. - does not support snapshots - I don't think there is a way to return the
stdout
so we cannot use our own assertions. - does not support background tasks, which is why I created the
startBackgroundProcess
utility. - does not play nice with windows, commands need to be appended with
.cmd
, see issue, they should useexeca
orcross-spawn
.
I think we should simply use execa
and ava
assertions instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems a great tool anyway, but those are big downside in our case. Maybe when we test a bigger command like aragon run
we will discover if only execa
and ava
is enough or we need at some point add other tooling
Finally made Travis work! First it was failing because of the lockfiles: github:ahultgren/async-eventemitter and github:frozeman/WebSocket-Node Then with Thirdly, because of OS specific text, see Ended up using hacky solution: running |
@@ -3,14 +3,17 @@ | |||
|
|||
# Dependencies | |||
node_modules | |||
*ipfs.cmd* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is created at the root folder when installing go-ipfs
on windows 🤷♂️
- npm run lint | ||
- npm run test | ||
- npm run build |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The build
script is automatically ran after install because of npm prepare
33242ad
to
ace33fa
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Working great 🎉
On |
Looks like it was an issue on my part actually 😅. |
Todo: