Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[completion] Stub for the _init_completion builtin.
With scripts to generate test cases from the bash oracle in Python format.
- Loading branch information
Andy Chu
committed
Dec 21, 2018
1 parent
725dfbf
commit 41492ff
Showing
10 changed files
with
211 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/usr/bin/python -S | ||
""" | ||
builtin_comp_test.py: Tests for builtin_comp.py | ||
""" | ||
from __future__ import print_function | ||
|
||
import unittest | ||
|
||
from core import alloc | ||
|
||
from osh import state | ||
from osh import builtin_comp # module under test | ||
|
||
from testdata.init_completion_testdata import CASES # generated data | ||
|
||
|
||
class BuiltinCompTest(unittest.TestCase): | ||
|
||
def testInitCompletion(self): | ||
arena = alloc.SideArena('<MakeTestEvaluator>') | ||
mem = state.Mem('', [], {}, arena) | ||
|
||
print(CASES) | ||
argv = [] | ||
|
||
# TODO: Look at variables | ||
|
||
builtin_comp.InitCompletion(['-s'], mem) | ||
|
||
print(mem.GetVar('words')) | ||
print(mem.GetVar('cur')) | ||
print(mem.GetVar('prev')) | ||
print(mem.GetVar('cword')) | ||
print(mem.GetVar('split')) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# | ||
# DO NOT EDIT -- Generated by testdata/init_completion.sh | ||
# | ||
|
||
CASES = [] | ||
|
||
case = {} | ||
CASES.append(case) | ||
case["code"] = 'echo foo:bar --color=auto\t' | ||
case["COMP_WORDS"] = ['echo', 'foo', ':', 'bar', '--color', '=', 'auto'] | ||
|
||
case = {} | ||
CASES.append(case) | ||
case["code"] = 'echo "foo:bar|" --color=auto\t' | ||
case["COMP_WORDS"] = ['echo', '"foo:bar|"', '--color', '=', 'auto'] | ||
|
||
|
||
case = {} | ||
CASES.append(case) | ||
case["code"] = 'noflags foo:bar --color=auto\t' | ||
case["words"] = ['noflags', 'foo', ':', 'bar', '--color', '=', 'auto'] | ||
case["cur"] = 'auto' | ||
case["prev"] = '=' | ||
case["cword"] = '6' | ||
case["split"] = '' | ||
|
||
case = {} | ||
CASES.append(case) | ||
case["code"] = 'noflags "foo:bar|" --color=auto\t' | ||
case["words"] = ['noflags', '"foo:bar|"', '--color', '=', 'auto'] | ||
case["cur"] = 'auto' | ||
case["prev"] = '=' | ||
case["cword"] = '4' | ||
case["split"] = '' | ||
|
||
case = {} | ||
CASES.append(case) | ||
case["code"] = 'noflags "foo:bar|\t' | ||
case["words"] = ['noflags', '"foo:bar|'] | ||
case["cur"] = '"foo:bar|' | ||
case["prev"] = 'noflags' | ||
case["cword"] = '1' | ||
case["split"] = '' | ||
|
||
|
||
case = {} | ||
CASES.append(case) | ||
case["code"] = 's foo:bar --color=auto\t' | ||
case["words"] = ['s', 'foo', ':', 'bar', '--color=auto'] | ||
case["cur"] = 'auto' | ||
case["prev"] = '--color' | ||
case["cword"] = '4' | ||
case["split"] = 'true' | ||
|
||
case = {} | ||
CASES.append(case) | ||
case["code"] = 's foo:bar --color auto\t' | ||
case["words"] = ['s', 'foo', ':', 'bar', '--color', 'auto'] | ||
case["cur"] = 'auto' | ||
case["prev"] = '--color' | ||
case["cword"] = '5' | ||
case["split"] = 'false' | ||
|
||
|
||
case = {} | ||
CASES.append(case) | ||
case["code"] = 'n foo:bar --color=auto\t' | ||
case["words"] = ['n', 'foo', ':', 'bar', '--color=auto'] | ||
case["cur"] = '--color=auto' | ||
case["prev"] = 'bar' | ||
case["cword"] = '4' | ||
case["split"] = '' | ||
|
||
|
||
case = {} | ||
CASES.append(case) | ||
case["code"] = 'n2 foo:bar --color=auto\t' | ||
case["words"] = ['n2', 'foo:bar', '--color=auto'] | ||
case["cur"] = '--color=auto' | ||
case["prev"] = 'foo:bar' | ||
case["cword"] = '2' | ||
case["split"] = '' |