Git Product home page Git Product logo

Comments (5)

gvwilson avatar gvwilson commented on September 21, 2024

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:

  1. compare a small number of files by hand
  2. 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.

machow avatar machow commented on September 21, 2024

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.

gvwilson avatar gvwilson commented on September 21, 2024

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.

machow avatar machow commented on September 21, 2024

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.

filipsch avatar filipsch commented on September 21, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.