summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Loehning <robert.loehning@qt.io>2016-05-26 18:51:15 +0200
committerRobert Loehning <robert.loehning@qt.io>2016-05-30 09:13:04 +0000
commitc1e7cf84e40a9c54577e614d626a4f5774708fec (patch)
treebf57d2bc9245cd144344e0c53f912db93ac3433c
parentb4e11b191becd0f5e2c405d9cd65ecb098d3faec (diff)
downloadqt-creator-c1e7cf84e40a9c54577e614d626a4f5774708fec.tar.gz
Squish: Do not use shell in getOutputFromCmdline
Change-Id: I731b119169063912cd3b528a1a6a58727002ae67 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
-rw-r--r--tests/system/shared/hook_utils.py8
-rw-r--r--tests/system/shared/project_explorer.py2
-rw-r--r--tests/system/shared/qtcreator.py2
-rw-r--r--tests/system/shared/utils.py6
-rw-r--r--tests/system/shared/workarounds.py10
-rw-r--r--tests/system/suite_general/tst_default_settings/test.py4
-rw-r--r--tests/system/suite_tools/tst_external_sort/test.py6
7 files changed, 20 insertions, 18 deletions
diff --git a/tests/system/shared/hook_utils.py b/tests/system/shared/hook_utils.py
index 89b1d6b230..16314fe50f 100644
--- a/tests/system/shared/hook_utils.py
+++ b/tests/system/shared/hook_utils.py
@@ -179,10 +179,10 @@ def __getMkspecFromQMakeConf__(qmakeConf):
return os.path.basename(mkspec)
def __getMkspecFromQmake__(qmakeCall):
- if getOutputFromCmdline("%s -query QT_VERSION" % qmakeCall).strip().startswith("5."):
- return getOutputFromCmdline("%s -query QMAKE_XSPEC" % qmakeCall).strip()
+ if getOutputFromCmdline([qmakeCall, "-query", "QT_VERSION"]).strip().startswith("5."):
+ return getOutputFromCmdline([qmakeCall, "-query", "QMAKE_XSPEC"]).strip()
else:
- QmakeConfPath = getOutputFromCmdline("%s -query QMAKE_MKSPECS" % qmakeCall).strip()
+ QmakeConfPath = getOutputFromCmdline([qmakeCall, "-query", "QMAKE_MKSPECS"]).strip()
for tmpPath in QmakeConfPath.split(os.pathsep):
tmpPath = tmpPath + os.sep + "default" + os.sep +"qmake.conf"
result = __getMkspecFromQMakeConf__(tmpPath)
@@ -326,7 +326,7 @@ def __isWinFirewallRunning__():
if not platform.system() in ('Microsoft' 'Windows'):
__isWinFirewallRunning__.fireWallState = False
return False
- result = getOutputFromCmdline("netsh firewall show state")
+ result = getOutputFromCmdline(["netsh", "firewall", "show", "state"])
for line in result.splitlines():
if "Operational mode" in line:
__isWinFirewallRunning__.fireWallState = not "Disable" in line
diff --git a/tests/system/shared/project_explorer.py b/tests/system/shared/project_explorer.py
index c98421788f..5103d72269 100644
--- a/tests/system/shared/project_explorer.py
+++ b/tests/system/shared/project_explorer.py
@@ -277,7 +277,7 @@ def getQtInformationByQMakeCall(qtDir, which):
else:
test.fatal("You're trying to fetch an unknown information (%s)" % which)
return None
- return getOutputFromCmdline("%s -query %s" % (qmake, query)).strip()
+ return getOutputFromCmdline([qmake, "-query", query]).strip()
def invokeContextMenuOnProject(projectName, menuItem):
try:
diff --git a/tests/system/shared/qtcreator.py b/tests/system/shared/qtcreator.py
index c9d2ee2782..265fa10107 100644
--- a/tests/system/shared/qtcreator.py
+++ b/tests/system/shared/qtcreator.py
@@ -118,7 +118,7 @@ def waitForCleanShutdown(timeOut=10):
if not shutdownDone and datetime.utcnow() > endtime:
break
if platform.system() == 'Linux' and JIRA.isBugStillOpen(15749):
- pgrepOutput = getOutputFromCmdline('pgrep -f qtcreator_process_stub')
+ pgrepOutput = getOutputFromCmdline(["pgrep", "-f", "qtcreator_process_stub"])
pids = pgrepOutput.splitlines()
if len(pids):
print("Killing %d qtcreator_process_stub instances" % len(pids))
diff --git a/tests/system/shared/utils.py b/tests/system/shared/utils.py
index 85cfb2f096..1429cb6c0f 100644
--- a/tests/system/shared/utils.py
+++ b/tests/system/shared/utils.py
@@ -139,7 +139,7 @@ def which(program):
command = "where"
else:
command = "which"
- foundPath = getOutputFromCmdline(command + " " + program)
+ foundPath = getOutputFromCmdline([command, program])
if foundPath:
return foundPath.splitlines()[0]
else:
@@ -216,9 +216,9 @@ def logApplicationOutput():
return None
# get the output from a given cmdline call
-def getOutputFromCmdline(cmdline):
+def getOutputFromCmdline(cmdline, environment=None):
try:
- return subprocess.check_output(cmdline, shell=True) # TODO: do not use shell=True
+ return subprocess.check_output(cmdline, env=environment)
except subprocess.CalledProcessError as e:
test.warning("Command '%s' returned %d" % (e.cmd, e.returncode))
return e.output
diff --git a/tests/system/shared/workarounds.py b/tests/system/shared/workarounds.py
index ae9cc9609a..d0a7ab0145 100644
--- a/tests/system/shared/workarounds.py
+++ b/tests/system/shared/workarounds.py
@@ -224,16 +224,18 @@ class JIRA:
def __tryExternalTools__(self, proxy=None):
global JIRA_URL
if proxy:
- cmdAndArgs = { 'curl':'-k --proxy %s' % proxy,
- 'wget':'-qO-'}
+ cmdAndArgs = { 'curl':['-k', '--proxy', proxy],
+ 'wget':['-qO-']}
else:
- cmdAndArgs = { 'curl':'-k', 'wget':'-qO-' }
+ cmdAndArgs = { 'curl':['-k'], 'wget':['-qO-']}
for call in cmdAndArgs:
prog = which(call)
if prog:
if call == 'wget' and proxy and os.getenv("https_proxy", None) == None:
test.warning("Missing environment variable https_proxy for using wget with proxy!")
- return getOutputFromCmdline('"%s" %s %s/%s-%d' % (prog, cmdAndArgs[call], JIRA_URL, self._bugType, self._number))
+ cmdline = [prog] + cmdAndArgs[call]
+ cmdline += ['%s/%s-%d' % (JIRA_URL, self._bugType, self._number)]
+ return getOutputFromCmdline(cmdline)
return None
# this function crops multiple whitespaces from fetched and searches for expected
diff --git a/tests/system/suite_general/tst_default_settings/test.py b/tests/system/suite_general/tst_default_settings/test.py
index b7bc5f41da..1568c6e114 100644
--- a/tests/system/suite_general/tst_default_settings/test.py
+++ b/tests/system/suite_general/tst_default_settings/test.py
@@ -165,7 +165,7 @@ def __getExpectedCompilers__():
if platform.system() in ('Linux', 'Darwin'):
compilers.extend(["g++-4.0", "g++-4.2", "clang++"])
if platform.system() == 'Darwin':
- xcodeClang = getOutputFromCmdline("xcrun --find clang++").strip("\n")
+ xcodeClang = getOutputFromCmdline(["xcrun", "--find", "clang++"]).strip("\n")
if xcodeClang and os.path.exists(xcodeClang) and xcodeClang not in expected:
expected.append(xcodeClang)
for compiler in compilers:
@@ -217,7 +217,7 @@ def __getExpectedDebuggers__():
result.extend(filter(lambda s: not ("lldb-platform" in s or "lldb-gdbserver" in s),
findAllFilesInPATH("lldb-*")))
if platform.system() == 'Darwin':
- xcodeLLDB = getOutputFromCmdline("xcrun --find lldb").strip("\n")
+ xcodeLLDB = getOutputFromCmdline(["xcrun", "--find", "lldb"]).strip("\n")
if xcodeLLDB and os.path.exists(xcodeLLDB) and xcodeLLDB not in result:
result.append(xcodeLLDB)
return result
diff --git a/tests/system/suite_tools/tst_external_sort/test.py b/tests/system/suite_tools/tst_external_sort/test.py
index 68d36841ea..95d8d93126 100644
--- a/tests/system/suite_tools/tst_external_sort/test.py
+++ b/tests/system/suite_tools/tst_external_sort/test.py
@@ -31,10 +31,10 @@ def main():
return
invokeMenuItem("File", "Open File or Project...")
unsortedFile = os.path.join(os.getcwd(), "testdata", "unsorted.txt")
- locale = ""
+ locale = None
if not platform.system() in ('Windows', 'Microsoft'):
- locale = "LC_ALL=C "
- sorted = getOutputFromCmdline("%ssort %s" % (locale, unsortedFile)).replace("\r", "")
+ locale = {"LC_ALL":"C"}
+ sorted = getOutputFromCmdline(["sort", unsortedFile], locale).replace("\r", "")
selectFromFileDialog(unsortedFile)
editor = waitForObject("{type='TextEditor::TextEditorWidget' unnamed='1' "
"visible='1' window=':Qt Creator_Core::Internal::MainWindow'}", 3000)