Closed OR13 closed 6 years ago
I recommend not reusing words such as task
for commands / agents. perhapse:
start task-submitter -a 0
submit-task -a 0 -t testTask.json
The vorpal stuff seems very reasonable.
In terms of commands, I agree that the task stuff seems confusing. I think we should do this:
start task -a 0
submit-task -a 0 -t testTask.json
Cool, I will continue, and use that approach.
Leaving this here for reference: https://github.com/dthree/cash/tree/master/test
Testing CLI's is difficult. The functions can be tested, or the full cli can be tested.
I think the best approach is to have vorpal call a library function, and then write tests for each of those functions. This saves you from needing to handle stdout/stderr.
Testing stdout would be fancy, but probably not necessary for the time. The functions that the cli's should be calling are mostly in the tests now, so I think that will be sufficient.
In terms of the UI, manually going through to check isn't too bad since there aren't too many commands at the moment.
I've taken some stylistic liberties here, happy to remove them (the dice). Just want to show what can be done. I've also held off on changing any of the naming until we are happy with behavior. Probably best not to mix that with this PR.
Regarding testing, I've added tests for the cliLIb which provides all the functions used by the cli.
This allows for unit testing of the cli behavior without the need to capture shell output.
From an organization standpoint it seems like this project should have unit tests around the cliLib, and flows.
For example, it is possible to use the cliLib to test flows of commands, for example cases where you do not initialize a solver, but call submitTask.
travis is so picky... this passed on my side. https://travis-ci.org/OR13/truebit-os/builds/389775141
I need to add the tests that I have written and test again.
Objective here is to get the cliLib tests to pass along side the os tests. I'm seeing some revert failure when running os-challenge.
This is caused by the addition of the verifier. The os-challenge
test does not actually test the verifier, and its presence causes failure.
I'm happy to tackle fixing that test in a separate pr.
If we are happy with travis tests passing in this form:
https://travis-ci.org/TrueBitFoundation/truebit-os/builds/390175190#L914
I suggest we merge this PR, and I can tackle the verifier (os-challenge) bit next.
I can also remove reference to the old shell and cleanup a bit, but I don't want to do that unless its requested.
Great work! Yes please remove any references of old shell, we have no use for it anymore.
Now we know why the builds were failing... If i had a penny for every-time truffle / testrpc / ganache / web3 version slipped and broke my stuff... I'd have lots of pennies....
https://travis-ci.org/TrueBitFoundation/truebit-os/jobs/391048018#L461
I'd say this is safe to merge now.
Looks good! Really appreciate the effort on this!
If this looks good, I can proceed to replicate all existing shell commands. vorpal can help enforce required arguments, but the existing shell seemed to use optional arguments as required. I defaulted them to make them optional, but they could also be made required, and no additional error handling logic would be needed.
https://github.com/dthree/vorpal/wiki/api-%7C-vorpal.command#vorpalcommandcommand-description
Since this tool is initially for testing, I recommend not making arguments required and picking reasonable defaults so the flow can be quickly run through, like so: