rpgle-repl icon indicating copy to clipboard operation
rpgle-repl copied to clipboard

Run test suites via command, non-interactively

Open JDubbTX opened this issue 1 year ago • 5 comments

It occurs to me that it would be powerful to have REPL tests available to run in a test suite, as part of a ci/cd pipeline.

I would like to be able to call REPL via bash command, and it return 0 if all tests pass, and not zero if there is a failure. It would be nice to have stdout be the screen output, controlled via parameter (like REPL -v REPLTESTS would print everything to stdout, while REPL REPLTESTS would not).

JDubbTX avatar Feb 25 '24 01:02 JDubbTX

Hey, are you imagining here that REPLTEST is a saved snippet (or collection of saved snippets) in REPL, or is it a separate source file? I could see both being useful - either to be able to run an existing snippet, or just get REPL to process a copy of an existing source file as though it had been typed in.

And are you thinking of some kind of built in assertion statement, e.g. something like:

x = doSomething();
replAssert(2.5: x);

And so verbose would print out something like Test passed, x=2.5 or Test failed, expected x=2.5, actual x=5.0

tom-writes-code avatar Feb 26 '24 08:02 tom-writes-code

Sorry for the late response. Yes, something like that. RPGUNIT has different kinds of assertions like assert true, assert false, assert equal, even something that searches the joblog for a particular message etc.

I think just assert equal would be enough to get started. Might be nice to have a list screen that shows which tests are passing / failing, etc. too

JDubbTX avatar Mar 15 '24 19:03 JDubbTX

Yeah, that's great. I'll have a think about how best to slot that in. I can definitely add in a few assertions, and then I'll look at wrapping it up in a shell script.

tom-writes-code avatar Mar 20 '24 14:03 tom-writes-code

OK, we're part way there. The GUI now supports replPrint() and replEquals() to check existing values and make assertions about existing values.

image

Next on my list is allow these to be executed remotely and print out the results - I'm planning on starting with using named snippets, and if I can extend to it, specify any source code stored anywhere else, and execute that within the repl framework

tom-writes-code avatar Mar 29 '24 14:03 tom-writes-code

Basic bash script added, with wrapper CL functions. Still to do:

  • [x] extend this to allow generic source files, not just repl snippets
  • [x] allow generic replPrint
  • [x] allow generic replEquals
  • [ ] documentation

tom-writes-code avatar May 02 '24 21:05 tom-writes-code