Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
should
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
26
Issues
26
List
Boards
Labels
Service Desk
Milestones
Merge Requests
4
Merge Requests
4
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vidjil
should
Commits
78bdaa74
Commit
78bdaa74
authored
Apr 22, 2018
by
Mathieu Giraud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
should, demo/*.should, src/should.py, README.md: brand the program as `should`
parent
4f016af4
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
17 deletions
+17
-17
README.md
README.md
+10
-10
demo/launcher.should
demo/launcher.should
+1
-1
demo/retry.should
demo/retry.should
+2
-2
src/should.py
src/should.py
+4
-4
No files found.
README.md
View file @
78bdaa74
[

](https://www.gnu.org/licenses/lgpl-3.0)
### `should
.py
` -- Test command-line applications through `.should` files
### `should` -- Test command-line applications through `.should` files
`should
.py
`
is a single-file program to test command-line applications.
`should`
is a single-file program to test command-line applications.
It checks the standard output, or possibly another file, and parses for exact or regular expressions,
possibly while counting them and checking their number of occurrences.
It outputs reports in
[
`.tap` format
](
https://testanything.org/tap-specification.html
)
and (soon, #1) in JUnit XML.
`should
.py
`
is written in Python 3 with no external dependencies and is intended to work on any command-line application
`should`
is written in Python 3 with no external dependencies and is intended to work on any command-line application
-- should your application outputs something, you can test it!
...
...
@@ -61,10 +61,10 @@ r: [Hh]ello,\s+world
```
The test is then run by calling
`should
.py
`
on the
`.should`
file:
The test is then run by calling
`should`
on the
`.should`
file:
```
shell
>
python3 src/should.py
demo/hello.should
>
./should
demo/hello.should
$LAUNCHER
=
demo/hello.should
...
...
@@ -89,11 +89,11 @@ demo/hello.should
```
`should
.py
`
can be run on several
`.should`
files at once. In this case, it furthers show statistics
`should`
can be run on several
`.should`
files at once. In this case, it furthers show statistics
on all tests. Here 39 out of 40 tests passed from 8
`.should`
files.
```
shell
>
python3 src/should.py
demo/
*
.should
>
./should
demo/
*
.should
(
...
)
Summary
==>
ok - ok:8 total:8 files
...
...
@@ -117,9 +117,9 @@ for example to launch tools like `valgrind` on a test set.
**Options and modifiers**
```
shell
python3 should.py
-h
./should
-h
usage: should
.py
[
-h
]
[
--cd
PATH]
[
--cd-same
]
[
--launcher
CMD]
usage: should
[
-h
]
[
--cd
PATH]
[
--cd-same
]
[
--launcher
CMD]
[
--mod
MODIFIERS]
[
--var
NAME
=
value]
[
--log
]
[
--tap
]
[
-v
]
[
-q
]
should-file
[
should-file ...]
...
...
@@ -152,7 +152,7 @@ output options:
**Output.**
By default,
`should
.py
`
only writes to the standard output.
By default,
`should`
only writes to the standard output.
The
`--log`
and the
`--tap`
options enable to store the actual output of the tested commands
as well as
[
`.tap` files
](
https://testanything.org/tap-specification.html
)
.
...
...
demo/launcher.should
View file @
78bdaa74
# The --launcher option allows to prepend something to every command.
# It could be used with valgrind or other tools.
python3 src/should.py
--launcher echo demo/cal.should ; true
./should
--launcher echo demo/cal.should ; true
$ The command is launched with 'echo'
: LANG=C cal 2001
...
...
demo/retry.should
View file @
78bdaa74
# should.py --retry relaunches the previous failed or warned tests,
# with the same options that at the first call.
python3 src/should.py
-v demo/hello.should demo/cal.should
python3 src/should.py
--retry
./should
-v demo/hello.should demo/cal.should
./should
--retry
$ 'cal.should' was labeled as 'TODO-but-ok' at both calls
rl: files with.*TODO-but-ok.*demo/cal.should.*Retrying
...
...
src/should.py
View file @
78bdaa74
#!/usr/bin/env python3
# should
.py
-- Test command-line applications through .should files
# should -- Test command-line applications through .should files
#
# Copyright (C) 2018 by CRIStAL (UMR CNRS 9189, Université Lille) and Inria Lille
# Contributors:
...
...
@@ -12,13 +12,13 @@
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# "should
.py
" is distributed in the hope that it will be useful,
# "should" is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with "should
.py
". If not, see <http://www.gnu.org/licenses/>
# along with "should". If not, see <http://www.gnu.org/licenses/>
import
sys
...
...
@@ -178,7 +178,7 @@ for (mod_char, mod_long, mod_help) in MODIFIERS:
parser
=
ArgParser
(
description
=
'Test command-line applications through .should files'
,
fromfile_prefix_chars
=
'@'
,
epilog
=
'''Example:
python3
%(prog)s demo/hello.should'''
,
%(prog)s demo/hello.should'''
,
formatter_class
=
argparse
.
RawTextHelpFormatter
)
options
=
ArgParser
(
fromfile_prefix_chars
=
'@'
)
# Can be used in !OPTIONS: directive
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment