Squish: Test first commit in git repo

Task-number: QTCREATORBUG-12755
Change-Id: Idf27f4bc19ec62ce10ca9367e0b32b8d2b031587
Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
This commit is contained in:
Robert Loehning
2015-01-09 10:55:37 +01:00
parent a304229c42
commit 6e2782b8b0

View File

@@ -1,6 +1,6 @@
############################################################################# #############################################################################
## ##
## Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ## Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies).
## Contact: http://www.qt-project.org/legal ## Contact: http://www.qt-project.org/legal
## ##
## This file is part of Qt Creator. ## This file is part of Qt Creator.
@@ -72,23 +72,26 @@ def checkOrFixCommitterInformation(labelName, lineEditName, expected):
test.log("Commit information invalid or missing - entering dummy value (%s)" % expected) test.log("Commit information invalid or missing - entering dummy value (%s)" % expected)
replaceEditorContent(lineEd, expected) replaceEditorContent(lineEd, expected)
def verifyClickCommit(): # Opens a commit's diff from a diff log
# param count is the number of the commit (1-based) in chronologic order
def __clickCommit__(count):
gitEditor = waitForObject(":Qt Creator_Git::Internal::GitEditor") gitEditor = waitForObject(":Qt Creator_Git::Internal::GitEditor")
fileName = waitForObject(":Qt Creator_FilenameQComboBox") fileName = waitForObject(":Qt Creator_FilenameQComboBox")
test.verify(waitFor('str(fileName.currentText).startswith("Git Log")', 1000), test.verify(waitFor('str(fileName.currentText).startswith("Git Log")', 1000),
"Verifying Qt Creator still displays git log inside editor.") "Verifying Qt Creator still displays git log inside editor.")
waitFor("'Initial Commit' in str(gitEditor.plainText)", 3000)
content = str(gitEditor.plainText) content = str(gitEditor.plainText)
noOfCommits = content.count("commit")
commit = None commit = None
# find second commit # find commit
try: try:
line = filter(lambda line: line.startswith("commit"), content.splitlines())[-2] # Commits are listed in reverse chronologic order, so we have to invert count
line = filter(lambda line: line.startswith("commit"), content.splitlines())[-count]
commit = line.split(" ", 1)[1] commit = line.split(" ", 1)[1]
except: except:
test.fail("Could not find the second commit - leaving test") test.fail("Could not find the %d. commit - leaving test" % count)
return return False
placeCursorToLine(gitEditor, line) placeCursorToLine(gitEditor, line)
for i in range(5): for i in range(30):
type(gitEditor, "<Left>") type(gitEditor, "<Left>")
# get the current cursor rectangle which should be positioned on the commit ID # get the current cursor rectangle which should be positioned on the commit ID
rect = gitEditor.cursorRect() rect = gitEditor.cursorRect()
@@ -97,9 +100,9 @@ def verifyClickCommit():
expected = 'Git Show "%s"' % commit expected = 'Git Show "%s"' % commit
test.verify(waitFor('str(fileName.currentText) == expected', 5000), test.verify(waitFor('str(fileName.currentText) == expected', 5000),
"Verifying editor switches to Git Show.") "Verifying editor switches to Git Show.")
diffShow = waitForObject(":Qt Creator_DiffEditor::Internal::DescriptionEditorWidget") description = waitForObject(":Qt Creator_DiffEditor::Internal::DescriptionEditorWidget")
waitFor('len(str(diffShow.plainText)) != 0', 5000) waitFor('len(str(description.plainText)) != 0', 5000)
show = str(diffShow.plainText) show = str(description.plainText)
expected = [{"commit %s" % commit:False}, expected = [{"commit %s" % commit:False},
{"Author: Nobody <nobody@nowhere.com>": False}, {"Author: Nobody <nobody@nowhere.com>": False},
{"Date:\s+\w{3} \w{3} \d{1,2} \d{2}:\d{2}:\d{2} \d{4}.*":True}] {"Date:\s+\w{3} \w{3} \d{1,2} \d{2}:\d{2}:\d{2} \d{4}.*":True}]
@@ -110,6 +113,14 @@ def verifyClickCommit():
test.verify(re.match(expLine, line), "Verifying commit header line '%s'" % line) test.verify(re.match(expLine, line), "Verifying commit header line '%s'" % line)
else: else:
test.compare(line, expLine, "Verifying commit header line.") test.compare(line, expLine, "Verifying commit header line.")
test.verify(description.readOnly,
"Verifying description editor widget is readonly.")
return True
def verifyClickCommit():
for i in range(1, 3):
if not __clickCommit__(i):
continue
changed = waitForObject(":Qt Creator_DiffEditor::SideDiffEditorWidget") changed = waitForObject(":Qt Creator_DiffEditor::SideDiffEditorWidget")
original = waitForObject(":Qt Creator_DiffEditor::SideDiffEditorWidget2") original = waitForObject(":Qt Creator_DiffEditor::SideDiffEditorWidget2")
waitFor('str(changed.plainText) != "Waiting for data..." ' waitFor('str(changed.plainText) != "Waiting for data..." '
@@ -117,6 +128,14 @@ def verifyClickCommit():
# content of diff editors is merge of modified files # content of diff editors is merge of modified files
diffOriginal = str(original.plainText) diffOriginal = str(original.plainText)
diffChanged = str(changed.plainText) diffChanged = str(changed.plainText)
if i == 1:
# diffChanged must completely contain main.cpp
mainCPP = readFile(os.path.join(srcPath, projectName, "main.cpp"))
test.verify(mainCPP in diffChanged,
"Verifying whether diff editor contains main.cpp file.")
test.verify(mainCPP not in diffOriginal,
"Verifying whether original does not contain main.cpp file.")
elif i == 2:
# diffChanged must completely contain the pointless_header.h # diffChanged must completely contain the pointless_header.h
pointlessHeader = readFile(os.path.join(srcPath, projectName, "pointless_header.h")) pointlessHeader = readFile(os.path.join(srcPath, projectName, "pointless_header.h"))
test.verify(pointlessHeader in diffChanged, test.verify(pointlessHeader in diffChanged,
@@ -128,8 +147,9 @@ def verifyClickCommit():
test.verify("HEADERS += mainwindow.h\n\n" in diffOriginal test.verify("HEADERS += mainwindow.h\n\n" in diffOriginal
and "pointless_header.h" not in diffOriginal, and "pointless_header.h" not in diffOriginal,
"Verifying whether original has no additional header in pro file.") "Verifying whether original has no additional header in pro file.")
test.verify(original.readOnly and changed.readOnly and diffShow.readOnly, test.verify(original.readOnly and changed.readOnly,
"Verifying all diff editor widgets are readonly.") "Verifying that the actual diff editor widgets are readonly.")
invokeMenuItem("Tools", "Git", "Local Repository", "Log")
def main(): def main():
startApplication("qtcreator" + SettingsPath) startApplication("qtcreator" + SettingsPath)