Comments (5)
Thanks @machow - cmp
will do what I need in the single-file case provided we can put the reference file containing the correct content somewhere that the learner won't see it (don't want to distract them). Unfortunately, it looks like there's no recursive option to cmp
as there is to diff
, so I'll either:
- compare a small number of files by hand
- use
diff
with appropriate flags
The first is probably the best option anyway, since I don't know how I'd give sensible error reporting in the second case.
So, where should I put the reference files? I presume I provision them in requirements.sh
?
from shellwhat.
provisioning in requirements.sh
sounds like the right move.
For (1), if it's useful, you can put the SCTs in a loop...
# cmp returns non-zero exit code (error) when files don't match
list_of_files = ['a.txt', 'b.txt']
for fname in list_of_files:
feedback = "some message"
cmd = 'cmp {fname} /some_dir/{fname}'.format(fname = fname)
Ex().test_expr_error(cmd, feedback)
alternatively, tests that don't have Ex
before them don't run right away and could be used later...
# defines tests but doesn't run yet
tests = [test_expr_error('cmp {0} /some_dir/{0}'.format(fname)) for fname in list_of_files]
# runs tests
Ex().multi(tests)
from shellwhat.
Thanks @machow - if the tests are in a loop, will the error reports from each be queued up somehow for the user to read, and will the final pass/fail status automatically be the conjunction of all the tests that were run?
from shellwhat.
Outside of logical tests like test_or
and test_correct
, SCTs stop running / give feedback at the first failure.
https://protowhat.readthedocs.io/en/latest/#module-protowhat.checks.check_logic
(edit: this happens because being able to run one SCT, often requires previous ones to pass)
from shellwhat.
In the refactored version of shellwhat
, there are examples of how has_expr_output()
can be used. Once you get used to it, it's pretty elegant.
from shellwhat.
Related Issues (20)
- Support ast-based testing functionality HOT 1
- Some nodes on AST need to be skipped HOT 1
- Set up travis + report code coverage HOT 1
- online tool for testing regular expressions HOT 1
- Implement Git SCTs HOT 6
- Support desktop execution of unit tests HOT 1
- Must be able to run one command for testing solution and show another to user HOT 1
- repl.run_command should NOT echo commands to the shell HOT 1
- Sub-exercise not reported in build error messages HOT 4
- Add the "success_msg" function HOT 1
- test_output_contains does not include errors HOT 4
- Move tests outside of shellwhat folder
- Research SCT problems with git and shell courses HOT 5
- Implement way to test use of ^C in shell courses HOT 1
- scts use text stripped of ANSI escapes by default HOT 1
- Implement way to check use of history commands in shell courses HOT 4
- allow penalty-free execution of whitelisted shell commands HOT 4
- strip ANSI by default for SCTs HOT 1
- set up travis ci
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from shellwhat.