datacamp / shellwhat

https://shellwhat.readthedocs.io
GNU Affero General Public License v3.0
2 stars 8 forks source link

Must be able to run one command for testing solution and show another to user #29

Closed gvwilson closed 6 years ago

gvwilson commented 6 years ago

We need to be able to lie to our learners in our shell courses (shell and Git). Here's the use case:

  1. We want the learner to run nano config.txt to create a new a configuration file.

  2. If we put that in the solution block for the exercise, automated testing fails (because we go into the editor and never come out).

  3. So instead we use echo nano config.txt and use test_student_typed with the regular expression '.*nano\s+config\.txt.*' to check.

  4. That makes the SCT pass, but when the learner asks to see the solution, they see the extra echo command rather than just the nano command.

In other exercises, the solution is cp /solutions/config.txt ./config.txt to copy a file with the correct data from the /solutions directory created when the Docker image is built into the right place. Again, this gets a file comparison SCT to pass, but when the learner looks at the solution, they don't see what we want them to see.

We run into something similar when we're teaching the man command. If the solution code is:

man cut

then automated testing fails, because man cut launches less, which hangs up waiting for the user to type q. To prevent this, we use:

man cut | cat

as the solution, because piping the output of man to another command suppresses the launch of the pager. Again, when the learner asks for the solution, they see something different from what they should run.

filipsch commented 6 years ago

@gvwilson This is related to https://github.com/datacamp/learn-features/issues/14, and shellwhat is not the place to fix this. The issue is on the backend level, so closing it here. Good to see the conversation going on the learn-features issue, though!