Skip to content

deal gracefully with OSError from learntris #59

@rpoyner-tri

Description

@rpoyner-tri

Example: maximally obtuse TDD programmer does exactly what the error messages indicate, and no more:

$ ./testris.py 

Testris is the test runner for Learntris. Learntris is
the part *you* write, in whatever language you prefer.

If you're seeing this message when you tried to run
testris.py, it means testris can't find your code!

Your first step is to write a *console-mode* program
(one that does absolutely nothing!) and tell testris
where to find it:

    ./testris.py [/path/to/learntris] [arguments]

The path should refer to a physical file on disk, so if
you need command line arguments, create a wrapper program.
The default path is "./learntris".

You can pass extra arguments that will be passed to the
guest learntris program.

If you need more help with setting up, try reading:
https://github.com/LearnProgramming/learntris/wiki/Getting-Set-Up

Once testris is able to launch your program, this message
will be replaced with instructions for implementing your
first feature.

File not found: ./learntris
$ touch learntris
$ ./testris.py 

[Errno 13] Permission denied
Couldn't run './learntris' due to a permission error.
Make sure your program is marked as an executable.
$ chmod a+x learntris 
$ ./testris.py 
--------------------------------------------------
Traceback (most recent call last):
  File "./testris.py", line 168, in main
    run_tests(cmdline, use_shell)
  File "./testris.py", line 134, in run_tests
    program = spawn(program_args, use_shell)
  File "./testris.py", line 84, in spawn
    stdout=subprocess.PIPE)
  File "/usr/lib/python2.7/subprocess.py", line 711, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1343, in _execute_child
    raise child_exception
OSError: [Errno 8] Exec format error
--------------------------------------------------
Oh no! Testris encountered an unexpected problem while
attempting to run your program. Please report the above
traceback in the issue tracker, so that we can help you
with the problem and provide a better error message in
the future.

  https://github.com/LearnProgramming/learntris/issues

There are probably tons of possibilities for OSError, and maybe not all of them can be gracefully handled without risking being misleading. Anyway, food for thought.

Metadata

Metadata

Assignees

Labels

tancorelated to new test runner

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions