aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Löhning <robert.loehning@qt.io>2023-03-13 17:16:19 +0100
committerRobert Löhning <robert.loehning@qt.io>2023-03-20 16:06:58 +0000
commite35ca21221505c76ddd9dc2fc012656e58be68ea (patch)
tree2e9b325146986ddb82bb95190bfdc03f999d519b
parenta84505bf7056cf669e0880351119a4fa1c18f101 (diff)
Squish: Add script for resetting MSVS' experimental instance
Change-Id: I3a07f16749c8ef924788cde27dc873ac8e5e1f5f Reviewed-by: Miguel Costa <miguel.costa@qt.io>
-rw-r--r--Tests/system/Readme.txt12
-rw-r--r--Tests/system/shared/globalnames.py3
-rw-r--r--Tests/system/shared/utils.py36
-rw-r--r--Tests/system/suite_installation/suite.conf2
-rw-r--r--Tests/system/suite_installation/tst_0_reset_testinstance/test.py42
-rw-r--r--Tests/system/suite_installation/tst_1_install_from_marketplace/test.py (renamed from Tests/system/suite_installation/tst_install_from_marketplace/test.py)0
-rw-r--r--Tests/system/suite_installation/tst_2_install_verify/test.py (renamed from Tests/system/suite_installation/tst_install_verify/test.py)0
-rw-r--r--Tests/system/suite_installation/tst_8_uninstall/test.py (renamed from Tests/system/suite_installation/tst_uninstall/test.py)0
-rw-r--r--Tests/system/suite_installation/tst_9_uninstall_verify/test.py (renamed from Tests/system/suite_installation/tst_uninstall_verify/test.py)0
9 files changed, 79 insertions, 16 deletions
diff --git a/Tests/system/Readme.txt b/Tests/system/Readme.txt
index 0ffc45b3..29f794d6 100644
--- a/Tests/system/Readme.txt
+++ b/Tests/system/Readme.txt
@@ -2,13 +2,19 @@ This directory contains tests for The Qt VS Tools to be run with Squish.
To run these tests:
1. Run Windows with English or German UI.
-2. Have Visual Studio with English language pack and Qt VS Tools installed.
+2. Have Visual Studio with English language pack and the Visual Studio SDK installed.
3. Open at least one of the test suites (suite.conf) in Squish for Windows.
4. In "Test Suite Settings", select devenv.exe as AUT.
-5. Run individual tests or the entire test suite.
+5. In Visual Studio, install the Qt VS Tools to be tested. You can do this manually or run the test
+ tst_1_install_from_marketplace from suite_installation. It will download the current version
+ from the marketplace and start its installation.
+6. Run individual tests or the entire test suite.
The tests will run in the experimental environment which you get when starting devenv.exe with
-parameters "/RootSuffix SquishTestInstance".
+parameters "/RootSuffix SquishTestInstance". Except for the preconditions listed above, each test
+is expected to set up what it needs and to clean up after itself. Should that fail for some reason,
+you can run tst_0_reset_testinstance from suite_installation to reset the environment. After doing
+so, you will have to install Qt VS Tools again.
Some tests require the following environment variables to be set to the correct values:
SQUISH_VSTOOLS_VERSION: The expected version of Qt VS Tools
diff --git a/Tests/system/shared/globalnames.py b/Tests/system/shared/globalnames.py
index 9c4f75b1..a5dd8784 100644
--- a/Tests/system/shared/globalnames.py
+++ b/Tests/system/shared/globalnames.py
@@ -14,3 +14,6 @@ pART_Popup_Popup = {"id": "", "name": "PART_Popup", "type": "Popup"}
pART_Popup_Exit_MenuItem = {"container": pART_Popup_Popup, "text": "Exit", "type": "MenuItem"}
pART_Popup_Qt_VS_Tools_MenuItem = {"container": pART_Popup_Popup, "text": "Qt VS Tools", "type": "MenuItem"}
extensions_MenuItem = {"container": microsoft_Visual_Studio_MenuBar, "text": "Extensions", "type": "MenuItem"}
+msvs_Skip_this_for_now_Button = {"container": microsoft_Visual_Studio_Window, "text": "Skip this for now.", "type": "Button"}
+msvs_Start_Visual_Studio_Button = {"container": microsoft_Visual_Studio_Window, "text": "Start Visual Studio", "type": "Button"}
+msvs_Not_now_maybe_later_Label = {"container": microsoft_Visual_Studio_Window, "text": "Not now, maybe later.", "type": "Label"}
diff --git a/Tests/system/shared/utils.py b/Tests/system/shared/utils.py
index a56e447c..079407a4 100644
--- a/Tests/system/shared/utils.py
+++ b/Tests/system/shared/utils.py
@@ -10,18 +10,30 @@ import subprocess
import globalnames
-def startAppGetVersion():
- appContext = startApplication("devenv /LCID 1033 /RootSuffix SquishTestInstance")
- try:
- vsDirectory = appContext.commandLine.strip('"').partition("\\Common7")[0]
- programFilesDir = os.getenv("ProgramFiles(x86)")
- plv = subprocess.check_output('"%s/Microsoft Visual Studio/Installer/vswhere.exe" '
- '-path "%s" -property catalog_productLineVersion'
- % (programFilesDir, vsDirectory))
- version = str(plv).strip("b'\\rn\r\n")
- except:
- test.fatal("Cannot determine used VS version")
- version = ""
+rootSuffix = "SquishTestInstance"
+
+
+def getAppProperty(property):
+ vsDirectory = currentApplicationContext().commandLine.strip('"').partition("\\Common7")[0]
+ programFilesDir = os.getenv("ProgramFiles(x86)")
+ plv = subprocess.check_output('"%s/Microsoft Visual Studio/Installer/vswhere.exe" '
+ '-path "%s" -property %s'
+ % (programFilesDir, vsDirectory, property))
+ return plv.decode().strip()
+
+
+def startAppGetVersion(waitForInitialDialogs=False):
+ startApplication("devenv /LCID 1033 /RootSuffix %s" % rootSuffix)
+ version = getAppProperty("catalog_productLineVersion")
+ if waitForInitialDialogs:
+ try:
+ if version == "2022":
+ clickButton(waitForObject(globalnames.msvs_Skip_this_for_now_Button, 10000))
+ else:
+ mouseClick(waitForObject(globalnames.msvs_Not_now_maybe_later_Label, 10000))
+ clickButton(waitForObject(globalnames.msvs_Start_Visual_Studio_Button))
+ except:
+ pass
mouseClick(waitForObject(globalnames.continueWithoutCode_Label))
return version
diff --git a/Tests/system/suite_installation/suite.conf b/Tests/system/suite_installation/suite.conf
index a736ee26..9eceb79d 100644
--- a/Tests/system/suite_installation/suite.conf
+++ b/Tests/system/suite_installation/suite.conf
@@ -3,6 +3,6 @@ ENVVARS=envvars
IMPLICITAUTSTART=0
LANGUAGE=Python
OBJECTMAPSTYLE=script
-TEST_CASES=tst_install_from_marketplace tst_install_verify tst_uninstall tst_uninstall_verify
+TEST_CASES=tst_0_reset_testinstance tst_1_install_from_marketplace tst_2_install_verify tst_8_uninstall tst_9_uninstall_verify
VERSION=3
WRAPPERS=Windows
diff --git a/Tests/system/suite_installation/tst_0_reset_testinstance/test.py b/Tests/system/suite_installation/tst_0_reset_testinstance/test.py
new file mode 100644
index 00000000..f9f7ebfc
--- /dev/null
+++ b/Tests/system/suite_installation/tst_0_reset_testinstance/test.py
@@ -0,0 +1,42 @@
+####################################################################################################
+# Copyright (C) 2023 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+####################################################################################################
+
+# -*- coding: utf-8 -*-
+
+source("../../shared/utils.py")
+
+import builtins
+import subprocess
+
+# This script does not actually test anything. It only resets the experimental environment the
+# tests are running in so you can start from scratch. After running the script, the environment
+# will not contain any user settings. Only nagsreens from first start will already be handled.
+
+
+def main():
+ # Start MSVS to determine its version and instanceID, then close it immediately.
+ version = startAppGetVersion(True)
+ vsVersionNr = {"2019":"16.0", "2022":"17.0"}[version]
+ vsInstance = "_".join([vsVersionNr, getAppProperty("instanceID")])
+ installationPath = getAppProperty("installationPath")
+ closeMainWindow()
+ # Wait for MSVS to shut down
+ waitFor("not currentApplicationContext().isRunning")
+ snooze(2)
+ # Reset the experimental environment
+ subprocess.check_output('"%s/VSSDK/VisualStudioIntegration/Tools/Bin/'
+ 'CreateExpInstance.exe" /Reset /VSInstance=%s /RootSuffix=%s'
+ % (installationPath, vsInstance, rootSuffix))
+ try:
+ # Start MSVS again to click away the nagscreens shown on first start
+ startAppGetVersion(True)
+ closeMainWindow()
+ except (LookupError, TypeError) as e:
+ if version != "2019":
+ raise
+ # After clicking away the nagscreens, MSVS2019 seems to restart itself. After the restart,
+ # Squish can't find objects anymore. Just ignore the thrown exception. The instance was
+ # reset already at that point.
+ test.log("Caught %s from MSVS2019" % builtins.type(e), str(e))
diff --git a/Tests/system/suite_installation/tst_install_from_marketplace/test.py b/Tests/system/suite_installation/tst_1_install_from_marketplace/test.py
index 323551c2..323551c2 100644
--- a/Tests/system/suite_installation/tst_install_from_marketplace/test.py
+++ b/Tests/system/suite_installation/tst_1_install_from_marketplace/test.py
diff --git a/Tests/system/suite_installation/tst_install_verify/test.py b/Tests/system/suite_installation/tst_2_install_verify/test.py
index df8a477c..df8a477c 100644
--- a/Tests/system/suite_installation/tst_install_verify/test.py
+++ b/Tests/system/suite_installation/tst_2_install_verify/test.py
diff --git a/Tests/system/suite_installation/tst_uninstall/test.py b/Tests/system/suite_installation/tst_8_uninstall/test.py
index f958ce42..f958ce42 100644
--- a/Tests/system/suite_installation/tst_uninstall/test.py
+++ b/Tests/system/suite_installation/tst_8_uninstall/test.py
diff --git a/Tests/system/suite_installation/tst_uninstall_verify/test.py b/Tests/system/suite_installation/tst_9_uninstall_verify/test.py
index 6579363e..6579363e 100644
--- a/Tests/system/suite_installation/tst_uninstall_verify/test.py
+++ b/Tests/system/suite_installation/tst_9_uninstall_verify/test.py