Permalink
Browse files

Fix broken unit tests.

Fix 'test/unit.sh all' so it exits zero when unit tests fail!

TODO: The unit tests results should be published as a safeguard against
this bug.

Also:
- Fix typo in releases.html.
- Remove comments in scripts/release.sh.
  • Loading branch information...
Andy Chu
Andy Chu committed Dec 10, 2017
1 parent 4b39805 commit ab0859569b94b04d6a60f5b1137c0ca77055e2e0
Showing with 26 additions and 26 deletions.
  1. +4 −0 build/codegen.sh
  2. +2 −2 core/cmd_exec_test.py
  3. +5 −3 core/completion_test.py
  4. +12 −7 core/state_test.py
  5. +1 −14 scripts/release.sh
  6. +2 −0 test/unit.sh
View
@@ -100,6 +100,10 @@ lexer() {
build/dev.sh fastlex
}
# TODO:
# asdl/run.sh gen-osh-python
# Size profiler for binaries. TODO: Fold this into benchmarks/
bloaty() { ~/git/other/bloaty/bloaty "$@"; }
View
@@ -37,7 +37,7 @@ def InitCommandParser(code_str):
def InitExecutor():
mem = state.Mem('', [], {})
mem = state.Mem('', [], {}, None)
status_lines = None # not needed for what we're testing
builtins = builtin.BUILTIN_DEF
funcs = {}
@@ -50,7 +50,7 @@ def InitExecutor():
def InitEvaluator():
mem = state.Mem('', [], {})
mem = state.Mem('', [], {}, None)
state.SetLocalString(mem, 'x', 'xxx')
state.SetLocalString(mem, 'y', 'yyy')
View
@@ -60,7 +60,7 @@ def testWordsAction(self):
print(list(A1.Matches(['f'], 0, 'f')))
def testExternalCommandAction(self):
mem = state.Mem('dummy', [], {})
mem = state.Mem('dummy', [], {}, None)
a = completion.ExternalCommandAction(mem)
print(list(a.Matches([], 0, 'f')))
@@ -82,7 +82,9 @@ def testShellFuncExecution(self):
w.parts.append(a)
# Set global COMPREPLY=(f1 f2)
pairs = [ast.assign_pair(ast.LhsName('COMPREPLY'), assign_op_e.Equal, w)]
pair = ast.assign_pair(ast.LhsName('COMPREPLY'), assign_op_e.Equal, w)
pair.spids.append(0) # dummy
pairs = [pair]
body_node = ast.Assignment(Id.Assign_None, [], pairs)
func_node.name = 'myfunc'
@@ -141,7 +143,7 @@ def testRootCompleter(self):
def _MakeTestEvaluator():
mem = state.Mem('', [], {})
mem = state.Mem('', [], {}, None)
exec_opts = state.ExecOpts()
ev = word_eval.CompletionWordEvaluator(mem, exec_opts)
return ev
View
@@ -14,17 +14,22 @@
var_flags_e = runtime.var_flags_e
def _InitMem():
# empty environment, no arena.
return state.Mem('', [], {}, None)
class MemTest(unittest.TestCase):
def testGet(self):
mem = state.Mem('', [], {})
mem = _InitMem()
mem.PushCall('my-func', ['a', 'b'])
print(mem.GetVar('HOME'))
mem.PopCall()
print(mem.GetVar('NONEXISTENT'))
def testSetVarClearFlag(self):
mem = state.Mem('', [], {})
mem = _InitMem()
print(mem)
mem.PushCall('my-func', ['ONE'])
@@ -179,7 +184,7 @@ def testSetVarClearFlag(self):
self.fail("Expected failure")
def testGetVar(self):
mem = state.Mem('', [], {})
mem = _InitMem()
# readonly a=x
mem.SetVar(
@@ -194,7 +199,7 @@ def testGetVar(self):
def testExportThenAssign(self):
"""Regression Test"""
mem = state.Mem('', [], {})
mem = _InitMem()
# export U
mem.SetVar(
@@ -209,7 +214,7 @@ def testExportThenAssign(self):
self.assertEqual({'U': 'u'}, e)
def testUnset(self):
mem = state.Mem('', [], {})
mem = _InitMem()
# unset a
mem.Unset(runtime.LhsName('a'), scope_e.Dynamic)
@@ -219,7 +224,7 @@ def testUnset(self):
mem.Unset(runtime.LhsIndexedName('a', 1), scope_e.Dynamic)
def testArgv(self):
mem = state.Mem('', [], {})
mem = _InitMem()
mem.PushCall('my-func', ['a', 'b'])
self.assertEqual(['a', 'b'], mem.GetArgv())
@@ -242,7 +247,7 @@ def testArgv(self):
self.assertEqual(['a', 'b'], mem.GetArgv())
def testArgv2(self):
mem = state.Mem('', ['x', 'y'], {})
mem = state.Mem('', ['x', 'y'], {}, None)
mem.Shift(1)
self.assertEqual(['y'], mem.GetArgv())
View
@@ -122,18 +122,6 @@ build-and-test() {
test/alpine.sh test-tar oil
}
# Release procedure after build-and-test:
#
# ./local.sh publish-doc
# ./local.sh publish-release
# ./local.sh publish-releases-html
# ./local.sh publish-spec
# TODO:
# - publish-unit
# - Update the doc/ "latest" redirect?
# - Publish Alpine test log? (along with build stats?)
_compressed-tarball() {
local name=${1:-hello}
local version=${2:-0.0.0}
@@ -603,11 +591,10 @@ _html-index() {
echo "<p class="date">$date</p>"
echo '<p> <a href="release/'$version'/announcement.html">Release Announcment</a>
echo '<p> <a href="release/'$version'/announcement.html">Release Announcement</a>
&nbsp; | &nbsp; <a href="release/'$version'/doc/INSTALL.html">INSTALL</a>
&nbsp; | &nbsp; <a href="release/'$version'/">Docs and Details</a>
</p>'
#&nbsp; | &nbsp; <a href="/release/'$version'/test/">Test Results</a>
_release-files-html $version
done < _tmp/sorted-releases.txt
View
@@ -123,6 +123,8 @@ _html-summary() {
if (num_failed == 0) {
print ""
print "ALL " num_passed " TESTS PASSED"
} else {
exit(1) # Fail
}
}
'

0 comments on commit ab08595

Please sign in to comment.