Skip to content

Commit

Permalink
disable sandbox on testing
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiommendes committed Mar 27, 2017
1 parent fff875e commit a05a51f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.2.5
0.2.6
18 changes: 14 additions & 4 deletions src/markio/__main__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import argparse
import os

import sys

Expand Down Expand Up @@ -38,7 +39,7 @@ def add_params(parser, input=False, debug=False, lang=False):

# "markio test" sub-command
parser_test = subparsers.add_parser('test',
help='check tests consistency')
help='check tests consistency')
add_params(parser_test, input=True, debug=True, lang=True)
parser_test.add_argument(
'--silent', '-s',
Expand Down Expand Up @@ -103,12 +104,16 @@ def markio_extract_source(args):
return md, source, lang


def markio_run(args):
def markio_run(args, sandbox=None):
"""
`markio run <file>` command.
"""

import ejudge

if sandbox is None:
sandbox = os.environ.get('MARKIO_SANDBOX', 'true') == 'true'

_, source, lang = markio_extract_source(args)
ejudge.exec(source, lang=lang)

Expand All @@ -126,17 +131,21 @@ def markio_src(args):
print(source)


def markio_test(args):
def markio_test(args, sandbox=None):
"""
`markio test <file>` command.
"""

import ejudge

if sandbox is None:
sandbox = os.environ.get('MARKIO_SANDBOX', 'true') == 'true'

md, source, lang = markio_extract_source(args)
iospec = md.tests
if args.expansions is not None:
iospec.expand_inputs(args.expansions)
results = ejudge.run(source, iospec, lang=lang)
results = ejudge.run(source, iospec, lang=lang, sandbox=sandbox)

if results.has_error_test_case:
for case, expected in zip(results, iospec):
Expand Down Expand Up @@ -168,6 +177,7 @@ def main(args=None):
else:
func(args)


parser = make_parser()

# Executed with `python -m markio`
Expand Down
2 changes: 1 addition & 1 deletion src/markio/__meta__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Automatically created. Please do not edit.
__version__ = u'0.2.5'
__version__ = u'0.2.6'
__author__ = u'F\xe1bio Mac\xeado Mendes'
4 changes: 4 additions & 0 deletions src/markio/tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def test_markio_cmd_shows_source_for_first_language():


def test_markio_run_works():
os.environ['MARKIO_SANDBOX'] = 'false'
path = os.path.join(DIRECTORY, 'hello-world.md')
with capture_print() as value:
with mock.patch('sys.exit', fake_exit):
Expand All @@ -80,6 +81,7 @@ def test_markio_run_works():


def test_markio_test_works():
os.environ['MARKIO_SANDBOX'] = 'false'
path = os.path.join(DIRECTORY, 'hello-world.md')
with capture_print() as value:
with mock.patch('sys.exit', fake_exit):
Expand All @@ -92,6 +94,7 @@ def test_markio_test_works():


def test_reading_invalid_markio():
os.environ['MARKIO_SANDBOX'] = 'false'
path = os.path.join(DIRECTORY, 'invalid-0.md')
with capture_print() as value:
try:
Expand All @@ -105,6 +108,7 @@ def test_reading_invalid_markio():

def test_testing_invalid_code():
path = os.path.join(DIRECTORY, 'invalid-1.md')
os.environ['MARKIO_SANDBOX'] = 'false'
with capture_print() as value:
try:
with mock.patch('sys.exit', fake_exit):
Expand Down

0 comments on commit a05a51f

Please sign in to comment.