dakusui / commandunit Goto Github PK
View Code? Open in Web Editor NEWA testing framework for command line tools.
Home Page: https://dakusui.github.io/commandunit/
License: MIT License
A testing framework for command line tools.
Home Page: https://dakusui.github.io/commandunit/
License: MIT License
Make it possible to reference environment variables from environmentVariables
section.
That is, what we want to do is the following, but the SCRIPTS_DIR
environment variable cannot be defined based on other environment variables.
---
"$extends":
- base/normal.json
when:
environmentVariables:
- SCRIPTS_DIR: "${COMMANDUNIT_HOSTFSROOT_MOUNTPOINT}/${COMMANDUNIT_PWD}/src/main/scripts"
source:
- ${COMMANDUNIT_DEPENDENCIES_ROOT}/bud/lib/core.rc
- ${COMMANDUNIT_HOSTFSROOT_MOUNTPOINT}/${COMMANDUNIT_PWD}/src/main/scripts/target_lib.rc
cmd: cat
args:
- ${SCRIPTS_DIR}/hello.txt
then:
exitCode:
- EQUAL
- 0
stdout:
present:
- REGEX:Hello world!
stderr:
absent:
- REGEX:.+
- ```
Improve documentation.
Perhaps, it's a good idea to make the commandunit-example
project a part of this project rather than keeping it separated.
Change default values of --xyzdir options because the behavior is not intuitive.
That is, I always use the following setting and it would be easier to understand the behavior
commandunit --test-srcdir=./src/test/scripts/ --test-workdir=./commandunit-out/work --test-reportdir=./commandunit-out/report
commandunit fails with the following output.
$ commandunit --native
/home/hiroshi/Documents/github/commandunit-example/src/dependencies/commandunit/src/main/scripts/bin/commandunit: line 77: COMMANDUNIT_PWD: unbound variable
ERROR:(exit code:1, pipe status: 1):
at src/dependencies/commandunit/src/main/scripts/dependencies/bud/lib/core.rc:54 (abort)
at src/dependencies/commandunit/src/main/scripts/bin/commandunit:77 (main)
at src/dependencies/commandunit/src/main/scripts/bin/commandunit:193 (main)
Command unit should set an appropriate for the environment variable no to bother uses to set it.
Although installation with docker is explained in the document, another way without docker is not explained.
While I was adding tests using commandunit, one of them requires curl command to be installed.
However, the docker image used for commandunit (You can see it here, which is originated in the image in jq-front).
I also got below error when I was trying to install curl command in the docker image that is launched by commandunit --debug-shell command.
I have no name!@8e93788c6fc1:/$ apt-get install curl E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied) E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?
If I add sudo to the beginning, I got this.
I have no name!@8e93788c6fc1:/$ sudo apt-get install curl bash: sudo: command not found
I'm not sure whether curl should be natively installed, but at least I'd like to have a capability to install another command required for the test.
Currently, the generated report (testreport.adoc
) contains a link (inclusion) shown below:
[%collapsible]
====
[source, json]
----
include::./core/test-cat.json[]
----
But this is not necessary and doesn't render with the following error:
This element should go away.
Unresolved directive in testreport.adoc - include::./core/test-cat.json[]
---
"$extends":
- base.json
This definition doesn't do $extends
but silently ignores the inheritance.
Introduce "clean" subcommand, which removes the report
and work
directories.
Implement clean subcommand.
It should cleans standard workdir (target
) at least.
Improve error message(s)
Error message for bailout is not informative.
Since commandunit
is designed to bailout when a malformed test script is given, this is very painful.
Where (how) can I find an execution log of command unit? Not the test related ones but framework side's.
commandunit fails with the following output:
INFO: Local repository path that has SSH Git URL '/Users/scott.tiger/Desktop/somewhere'
mkdir: cannot create directory '/tmp/bud': No space left on device
ERROR:(exit code:1, pipe status: 1):
at /app/dependencies/bud/lib/core.rc:54 (abort)
Some other users can successfully use commandunit (non-native) on macOS.
The only known difference is
If TMPDIR
is not set -> This failure is observed.
If TMPDIR
is set (Something like /var/folders/c9/ndzj29354pn6h9hcjqz6gy15j6nqy4/T/
) -> This failure is not observed.
We don't have knowledge about what component is (should be) responsible for defining TMPDIR
environment variable in macOS.
(Help needed)
Rename commandunit
script to commandunit-main
since a user facing script (wrapper script) should be named commandunit
and it will be confusing if two files have the same name.
Implement none subcommand, which doesn't do anything.
I have a script file(scriptA.sh) which sources scriptB.sh;
scriptA.sh
#!/usr/bin/env bash
source scriptB.sh
when I create commandunit script such as below and source scriptA.sh, commandunit cannot find scriptB.sh file and giving ".../scriptA.sh: line 6: /dev/scriptB.sh: No such file or directory" error message.
test.yaml
"$extends":
- some.json
when:
source:
-scriptA.sh
cmd:
then:
exitCode:
- EQUAL
- 0
Update commandunit function.
In the commandunit-example
project, there is an improved version of commandunit
function and it should be imported to the main project side.
How to reproduce
$ commandunit run mkdir: cannot create directory '/var/lib/commandunit/Users/<user_name>/Desktop/dev/gspci-shared-resources/gspci/src/test/target': Permission denied ERROR:(exit code:1, pipe status: 1): at /app/dependencies/bud/lib/core.rc:54 (abort) at /app/bin/commandunit:138 (main) at /app/bin/commandunit:193 (main)
commandunit
print help message as follows:
Usage: commandunit [OPTION]... [SUBCOMMAND]...
Runs tests.
Sub-commands:
preprocess:
Preprocesses test definition files (yaml++, yaml, and json++) and convert them into executable JSON test files
run:
Runs tests under a directory specified by --test-workdir and writes a report file: testreport.json under a
directory specified by --test-reportdir.
report:
Reads a file testreport.json under directory specified by --test-reportdir and renders a report file (testreport.adoc)
under the same directory.
-h, --help show this help
-p, --parallel execute the tests in parallel
-f, --filter filter tests with the specified regular expression(default:'.*')
--commandunit-dir directory to store config and data files (default: current {directory/.commandunit})
--project-name set project name of the test execution. used as the report's title(default:'unknown')
--test-srcdir write test reports under the specified directory (default: current directory)
--test-workdir write test reports under the specified directory (default: value for --test-srcdir + .commandunit/work)
--test-reportdir write test reports under the specified directory (default: value for --test-workdir)
--ignore-mtime ignore mtime and forcibly compile tests
--clean clean working directory
--tapview show test progress with 'tapview'
Examples:
commandunit Run tests found under current directory in sequential mode.
commandunit --srcdir=DIR Run tests found under DIR in sequential mode.
commandunit --srcdir=DIR -p Run tests found under DIR in parallel mode.
- documentation: <https://dakusui.github.io/commandunit/>
- github project: <https://github.com/dakusui/bud>
This will be better.
Usage: commandunit [OPTION]... [SUBCOMMAND]...
Runs tests.
Sub-commands:
preprocess:
Preprocesses test definition files (yaml++, yaml, and json++) and convert them into executable JSON test files
run:
Runs tests under a directory specified by --test-workdir and writes a report file: testreport.json under a
directory specified by --test-reportdir.
report:
Reads a file testreport.json under directory specified by --test-reportdir and renders a report file (testreport.adoc)
under the same directory.
-h, --help show this help
-p, --parallel execute the tests in parallel
-f, --filter filter tests with the specified regular expression(default:'.*')
--commandunit-dir directory to store config and data files (default: current {directory/.commandunit})
--project-name set project name of the test execution. used as the report's title(default:'unknown')
--test-srcdir execute tests under the specified directory (default: current directory)
--test-workdir set a working directory to the specified directory (default: value for --test-srcdir + .commandunit/work)
--test-reportdir write test reports under the specified directory (default: value for --test-workdir)
--ignore-mtime ignore mtime and forcibly compile tests
--clean clean working directory
--tapview show test progress with 'tapview'
Examples:
commandunit Run tests found under current directory in sequential mode.
commandunit --srcdir=DIR Run tests found under DIR in sequential mode.
commandunit --srcdir=DIR -p Run tests found under DIR in parallel mode.
- documentation: <https://dakusui.github.io/commandunit/>
- github project: <https://github.com/dakusui/bud>
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.