Skip to content

Commit

Permalink
Merge pull request #212 from facebook/testAllInput
Browse files Browse the repository at this point in the history
[AllInput] Followup to #211 add UI testing
  • Loading branch information
pcottle committed Nov 27, 2015
2 parents 030a640 + e3316c5 commit fcaf53d
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 9 deletions.
30 changes: 30 additions & 0 deletions src/__tests__/expected/allInputBranch.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
fix3
|===>gh-pages
* master
testAllInput
trunk























________________________________________________________________________________
[f|A] selection, [down|j|up|k|space|b] navigation, [x] quick select mode, [c] co
5 changes: 5 additions & 0 deletions src/__tests__/inputs/gitBranch.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
fix3
gh-pages
* master
testAllInput
trunk
9 changes: 6 additions & 3 deletions src/__tests__/screenTestRunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@
INPUT_DIR = './inputs/'


def getLineObjsFromFile(inputFile, validateFileExists):
def getLineObjsFromFile(inputFile, validateFileExists, allInput):
inputFile = os.path.join(INPUT_DIR, inputFile)
file = open(inputFile)
lines = file.read().split('\n')
file.close()
return processInput.getLineObjsFromLines(lines,
validateFileExists=validateFileExists)
validateFileExists=validateFileExists,
allInput=allInput)


def getRowsFromScreenRun(
Expand All @@ -41,10 +42,12 @@ def getRowsFromScreenRun(
pastScreen=None,
pastScreens=None,
validateFileExists=False,
allInput=False,
args=[]):

lineObjs = getLineObjsFromFile(inputFile,
validateFileExists=validateFileExists)
validateFileExists=validateFileExists,
allInput=allInput)
screen = ScreenForTest(
charInputs,
maxX=screenConfig.get('maxX', 80),
Expand Down
6 changes: 4 additions & 2 deletions src/__tests__/testParsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@
'match': 'no changes added to commit (use "git add" and/or "git commit -a")'
}]


class TestParseFunction(unittest.TestCase):

def testPrependDir(self):
Expand Down Expand Up @@ -445,9 +446,10 @@ def testAllInputMatches(self):

(match, _, _) = result
self.assertEqual(match, testCase['match'], 'Line "%s" did not match.' %
testCase['input'])
testCase['input'])

print('Tested %d cases for all-input matching.' % len(allInputTestCases))
print('Tested %d cases for all-input matching.' %
len(allInputTestCases))

def checkFileResult(self, testCase):
result = parse.matchLine(testCase['input'],
Expand Down
11 changes: 9 additions & 2 deletions src/__tests__/testScreen.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,11 @@
'name': 'selectAllBug',
'input': 'gitLongDiff.txt',
'inputs': ['A'],
}, {
'name': 'allInputBranch',
'input': 'gitBranch.txt',
'args': ['-ai'],
'inputs': ['j', 'f'],
}]


Expand All @@ -153,15 +158,17 @@ def testScreenInputs(self):
charInputs = ['q'] # we always quit at the end
charInputs = testCase.get('inputs', []) + charInputs

args = testCase.get('args', [])
screenData = screenTestRunner.getRowsFromScreenRun(
inputFile=testCase.get('input', 'gitDiff.txt'),
charInputs=charInputs,
screenConfig=testCase.get('screenConfig', {}),
printScreen=False,
pastScreen=testCase.get('pastScreen', None),
pastScreens=testCase.get('pastScreens', None),
args=testCase.get('args', []),
validateFileExists=testCase.get('validateFileExists', False)
args=args,
validateFileExists=testCase.get('validateFileExists', False),
allInput=('-ai' in args or '--all-input' in args),
)

self.compareToExpected(testCase, testName, screenData)
Expand Down
2 changes: 1 addition & 1 deletion src/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def composeFileCommand(command, lineObjs):
if '$F' in command:
command = command.replace('$F', path_str)
else:
command = command + ' ' + path_str
command = command + ' ' + path_str
return command


Expand Down
3 changes: 2 additions & 1 deletion src/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ def matchLine(line, validateFileExists=False, allInput=False):
if not validateFileExists:
results = matchLineImpl(line, withAllLinesMatched=allInput)
return results[0] if results else None
results = matchLineImpl(line, withFileInspection=True, withAllLinesMatched=allInput)
results = matchLineImpl(
line, withFileInspection=True, withAllLinesMatched=allInput)
if not results:
return None
# ok now we are going to check if this result is an actual
Expand Down

0 comments on commit fcaf53d

Please sign in to comment.