this post was submitted on 02 Nov 2023
7 points (88.9% liked)

Shell Scripting

1367 readers
1 users here now

From Ash, Bash and Csh to Xonsh, Ysh and Zsh; all shell languages are welcome here!

Rules:
  1. Follow Lemmy rules!
  2. Posts must relate to shell scripting. (See bottom of sidebar for more information.)
  3. Only make helpful replies to questions. This is not the place for low effort joke answers.
  4. No discussion about piracy or hacking.
  5. If you find a solution to your problem by other means, please take your time to write down the steps you used to solve your problem in the original post. You can potentially help others having the same problem!
  6. These rules will change as the community grows.

Keep posts about shell scripting! Here are some guidelines to help:


In general, if your submission text is primarily shell code, then it is welcome here!

founded 2 years ago
MODERATORS
 

This is not my work, but the author (same author as zsh-abbr) posted it elsewhere and it looks good to me.

In his words:

What is zsh-test-runner? A simple testing framework for zsh, and to a degree —thanks to zsh's emulation of other shells— csh, ksh, and sh.

The immediately noticeable difference between zsh-test-runner and other shell script unit test frameworks is it doesn't have a DSL. zsh-test-runner relies entirely on the shell's own testing. For those familiar with other frameworks: nothing like ShellSpec's Describe … When call … The output should, or shUnit2's assertEquals, or ZUnit's assert; zsh-test-runner is closer to Bats if you were to restrict yourself to core and not use helper libraries (there's nothing like bats-assert's assertEquals or bats-file's assert_dir_exists).

Why no special syntax? It means there's little new to learn— For example, if you know how to test numeric equality in your shell, you know how to test equality in zsh-test-runner; if you don't, there are community resources available. It means every possible test is supported equally out of the box— zsh-test-runner is a newcomer, but there are no "shoot my assertion method isn't supported" blockers. It means the cost of porting homegrow framework-less tests to zsh-test-runner is about as low as can be— generally speaking, my_cool_test_code becomes ztr test 'my_cool_test_code'. It means tests can live comfortably in one LOC, making zsh-test-runner pleasant to use in the terminal.

no comments (yet)
sorted by: hot top controversial new old
there doesn't seem to be anything here