Permalink
Browse files

Verify output commands with whitespaces with any order

  • Loading branch information...
Abergard authored and cslux committed Nov 12, 2018
1 parent 194cd70 commit cb044149d00e0e7b695b02de95e77a8a7bc77c7e
Showing with 23 additions and 23 deletions.
  1. +11 −11 tests/automated/Completion/expectation.json
  2. +12 −12 tests/automated/test_runner.py
@@ -4,23 +4,23 @@
"rc-command": [ "--code-complete-at", "{0}/main.cpp:12:15",
"--synchronous-completions"],
"expectation": [ "get int get() CXXMethod Foo",
"validate void validate(int) CXXMethod Foo",
"Foo Foo:: ClassDecl Foo",
"operator= Foo & operator=(const Foo &) CXXMethod Foo",
"operator= Foo & operator=(Foo &&) CXXMethod Foo",
"~Foo void ~Foo() CXXDestructor Foo",
"expectation": [ " get int get() CXXMethod Foo ",
" validate void validate(int) CXXMethod Foo ",
" Foo Foo:: ClassDecl Foo ",
" operator= Foo & operator=(const Foo &) CXXMethod Foo ",
" operator= Foo & operator=(Foo &&) CXXMethod Foo ",
" ~Foo void ~Foo() CXXDestructor Foo ",
""] },
{ "name": "completion should not show not accessible/private items",
"rc-command": [ "--code-complete-at", "{0}/main.cpp:20:7",
"--synchronous-completions"],
"expectation": [ "get int get() CXXMethod Foo",
"Foo Foo:: ClassDecl Foo",
"operator= Foo & operator=(const Foo &) CXXMethod Foo",
"operator= Foo & operator=(Foo &&) CXXMethod Foo",
"~Foo void ~Foo() CXXDestructor Foo",
"expectation": [ " get int get() CXXMethod Foo ",
" Foo Foo:: ClassDecl Foo ",
" operator= Foo & operator=(const Foo &) CXXMethod Foo ",
" operator= Foo & operator=(Foo &&) CXXMethod Foo ",
" ~Foo void ~Foo() CXXDestructor Foo ",
""] }
]
@@ -20,7 +20,15 @@
import json
import time
import subprocess as sp
from hamcrest import assert_that, has_length, has_item, empty, is_not, equal_to
from hamcrest import (
assert_that,
has_length,
has_item,
empty,
is_not,
equal_to,
contains_inanyorder
)
try:
FileNotFoundError
@@ -106,20 +114,12 @@ def run_parse(test_dir, rc_command, expected):
assert_that(output, is_not(empty()))
assert_that(output.split(" "), has_item(expected.format(test_dir + "/")))
def non_empty_split(string, delim=None):
"""Split string and return parts as list if not empty."""
return [x for x in string.split(delim) if x]
def run_completion(test_dir, rc_command, expected):
"""Run a completion test, and compare with EXPECTED output."""
outputs = run_rc([c.format(test_dir) for c in rc_command]).split("\n")
size = len(outputs)
assert_that(size, equal_to(len(expected)))
for i in range(0, size):
assert_that(non_empty_split(outputs[i].strip(), " "),
equal_to(non_empty_split(expected[i].strip(), " ")))
assert_that(len(outputs), equal_to(len(expected)))
for output in outputs:
assert_that(expected, has_item(output))
def run(test_dir, rc_command, expected, test_type):
"""Run test."""

0 comments on commit cb04414

Please sign in to comment.