1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
# Copyright (C) 2016 The Qt Company Ltd.
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
source("../../shared/qtcreator.py")
project = "untitled"
def main():
outputQDebug = "Output from qDebug()."
outputStdOut = "Output from std::cout."
outputStdErr = "Output from std::cerr."
startQC()
if not startedWithoutPluginError():
return
createProject_Qt_Console(tempDir(), project)
mainEditor = waitForObject(":Qt Creator_CppEditor::Internal::CPPEditorWidget")
replaceEditorContent(mainEditor, "")
typeLines(mainEditor, ["#include <QDebug>",
"#include <QThread>",
"#include <iostream>",
"struct Waiter:public QThread{Waiter(){QThread::sleep(2);}};",
"int main(int, char *argv[])",
"{",
'std::cout << \"' + outputStdOut + '\" << std::endl;',
'std::cerr << \"' + outputStdErr + '\" << std::endl;',
'qDebug() << \"' + outputQDebug + '\";',
'Waiter();'])
# Rely on code completion for closing bracket
invokeMenuItem("File", "Save All")
openDocument(project + ".CMakeLists\\.txt")
projectFileEditor = waitForObject(":Qt Creator_TextEditor::TextEditorWidget")
projectFileContent = str(projectFileEditor.plainText)
test.verify("Widgets" not in projectFileContent and "MACOSX_BUNDLE" not in projectFileContent,
"Verifying that program is configured with console")
availableConfigs = iterateBuildConfigs()
if not availableConfigs:
test.fatal("Haven't found a suitable Qt version - leaving without building.")
for kit, config in availableConfigs:
selectBuildConfig(kit, config)
test.log("Testing build configuration: " + config)
test.log("Running application")
setRunInTerminal(kit, False)
clickButton(waitForObject(":*Qt Creator.Run_Core::Internal::FancyToolButton"))
ensureChecked(":Qt Creator_AppOutput_Core::Internal::OutputPaneToggleButton")
outputWindow = waitForObject(":Qt Creator_Core::OutputWindow")
waitFor("'exited with code' in str(outputWindow.plainText) or \
'The program has unexpectedly finished' in str(outputWindow.plainText)", 20000)
try:
appOutput = str(waitForObject(":Qt Creator_Core::OutputWindow").plainText)
verifyOutput(appOutput, outputStdOut, "std::cout", "Application Output")
verifyOutput(appOutput, outputStdErr, "std::cerr", "Application Output")
if (kit == Targets.DESKTOP_5_4_1_GCC
and platform.system() in ('Windows', 'Microsoft')):
test.log("Skipping qDebug() from %s (unstable, QTCREATORBUG-15067)"
% Targets.getStringForTarget(Targets.DESKTOP_5_4_1_GCC))
else:
verifyOutput(appOutput, outputQDebug,
"qDebug()", "Application Output")
clickButton(waitForObject(":Qt Creator_CloseButton"))
except:
test.fatal("Could not find Application Output Window",
"Did the application run at all?")
test.log("Debugging application")
isMsvc = isMsvcConfig(kit)
invokeMenuItem("Debug", "Start Debugging", "Start Debugging of Startup Project")
handleDebuggerWarnings(config, isMsvc)
ensureChecked(":Qt Creator_AppOutput_Core::Internal::OutputPaneToggleButton")
outputWindow = waitForObject(":Qt Creator_Core::OutputWindow")
waitFor("'Debugging has finished' in str(outputWindow.plainText)", 20000)
try:
debuggerLog = takeDebuggerLog()
if not isMsvc:
# cout works with MSVC, too, but we don't check it since it's not supported
verifyOutput(debuggerLog, outputStdOut, "std::cout", "Debugger Log")
verifyOutput(debuggerLog, outputStdErr, "std::cerr", "Debugger Log")
verifyOutput(debuggerLog, outputQDebug, "qDebug()", "Debugger Log")
except LookupError:
# takeDebuggerLog() expects the debugger log to not be visible.
# If debugger log showed up automatically, previous call to takeDebuggerLog() has closed it.
debuggerLog = takeDebuggerLog()
if "lib\qtcreatorcdbext64\qtcreatorcdbext.dll cannot be found." in debuggerLog:
test.fatal("qtcreatorcdbext.dll is missing in lib\qtcreatorcdbext64")
else:
test.fatal("Debugger log did not behave as expected. Please check manually.")
switchViewTo(ViewConstants.EDIT)
ensureChecked(":Qt Creator_AppOutput_Core::Internal::OutputPaneToggleButton")
try:
appOutput = str(waitForObject(":Qt Creator_Core::OutputWindow").plainText)
if not isMsvc:
verifyOutput(appOutput, outputStdOut, "std::cout", "Application Output")
verifyOutput(appOutput, outputStdErr, "std::cerr", "Application Output")
verifyOutput(appOutput, outputQDebug, "qDebug()", "Application Output")
clickButton(waitForObject(":Qt Creator_CloseButton"))
except:
test.fatal("Could not find Application Output Window",
"Did the application run at all?")
progressBarWait(10000, False) # wait for "Build" progressbar to disappear
invokeMenuItem("File", "Exit")
|