Permalink
Browse files

Fix a couple errors caught by flake8.

Fix a pattern in test/unit.sh that caused osh/arith_parse_test.py not to
run.  Fix that unit test.

One error left.
  • Loading branch information...
Andy Chu
Andy Chu committed Feb 2, 2018
1 parent 95e2e32 commit 309b0a4d9bdfce74377a3f784b8883d360ff7e3a
Showing with 16 additions and 17 deletions.
  1. +1 −1 asdl/asdl_.py
  2. +1 −1 core/test_lib.py
  3. +1 −1 core/util.py
  4. +10 −11 osh/arith_parse_test.py
  5. +3 −3 test/unit.sh
View
@@ -163,7 +163,7 @@ def ResolveTypes(module, app_types=None):
_CheckFieldsAndWire(cons, type_lookup)
else:
raise AssertionError(typ)
raise AssertionError(v)
return type_lookup
View
@@ -67,5 +67,5 @@ def AssertAsdlEqual(test, left, right):
def MakeArena(source_name):
pool = alloc.Pool()
arena = pool.NewArena()
arena.PushSource('<lex_test.py>')
arena.PushSource(source_name)
return arena
View
@@ -254,7 +254,7 @@ def __init__(self, argv0):
def open(self, rel_path):
contents = self.z.get_data(rel_path)
return io.BytesIO(contents)
return cStringIO.StringIO(contents)
_loader = None
View
@@ -12,9 +12,12 @@
import unittest
from core import expr_eval
from core import legacy
from core import tdop
from core import word_eval
from core import cmd_exec
from core import state
from core import test_lib
from osh import parse_lib
#from osh import arith_parse
@@ -25,7 +28,8 @@ class ExprSyntaxError(Exception):
def ParseAndEval(code_str):
w_parser, _ = parse_lib.MakeParserForCompletion(code_str)
arena = test_lib.MakeArena('<arith_parse_test.py>')
w_parser, _ = parse_lib.MakeParserForCompletion(code_str, arena)
#spec = arith_parse.MakeShellSpec()
#a_parser = tdop.TdopParser(spec, w_parser) # Calls ReadWord(lex_mode_e.ARITH)
#anode = a_parser.Parse()
@@ -36,18 +40,13 @@ def ParseAndEval(code_str):
print('node:', anode)
mem = state.Mem('', [])
mem = state.Mem('', [], {}, None)
exec_opts = state.ExecOpts(mem)
ev = word_eval.CompletionWordEvaluator(mem, exec_opts)
arith_ev = expr_eval.ArithEvaluator(mem, ev, exec_opts)
ok = arith_ev.Eval(anode)
if ok:
value = arith_ev.Result()
print('value:', value)
else:
raise AssertionError(code_str)
splitter = legacy.SplitContext(mem)
ev = word_eval.CompletionWordEvaluator(mem, exec_opts, splitter)
arith_ev = expr_eval.ArithEvaluator(mem, exec_opts, ev)
value = arith_ev.Eval(anode)
return value
View
@@ -44,9 +44,9 @@ banner() {
tests-to-run() {
# TODO: Add opy.
for t in {build,test,native,asdl,core,osh,tools}/*_test.py; do
# NOTE: This test hasn't passed in awhile. It uses strings as output.
if [[ $t == *arith_parse_test.py ]]; then
for t in {build,test,native,asdl,core,osh,test,tools}/*_test.py; do
# This test doesn't pass because it uses strings. Maybe remove it.
if [[ $t == asdl/arith_parse_test.py ]]; then
continue
fi
echo $t

0 comments on commit 309b0a4

Please sign in to comment.