source: sasview/build_tools/sasview_deploy_test.au3 @ 1cecc91

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalccostrafo411magnetic_scattrelease-4.1.1release-4.1.2release-4.2.2release_4.0.1ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change on this file since 1cecc91 was 1cecc91, checked in by Piotr Rozyczko <rozyczko@…>, 6 years ago

Updated deployment test script

  • Property mode set to 100755
File size: 5.2 KB
Line 
1; ****** REMEMBER TO SWITCH OFF UAC ON TARGET MACHINE!!! *********
2;
3; This script will install, run and uninstall SasView
4; given location of the installer. The exit code of the script
5; points at failure location:
6;
7; 0 - OK
8; 1 - Download failure
9; 2 - Installer failure
10; 3 - Problems running SasView (simple fitting)
11; 4 - Uninstaller failure
12
13#include <Constants.au3>
14#include <FileConstants.au3>
15#include <MsgBoxConstants.au3>
16#include <InetConstants.au3>
17#include <WinAPIFiles.au3>
18
19; Custom error handler
20;Global $oMyError = ObjEvent("AutoIt.Error","MyErrFunc")
21
22; Modifiable globals
23if $CmdLine[0] == 0 Then
24   ; Expected command line with the build number as argument
25   Exit (-1)
26EndIf
27
28Local $lBuildNumber = $CmdLine[1]
29;Global $fInstallerLocation = "C:\util\setupSasView.exe" ; debug and testing location
30Global $fInstallerLocation = @TempDir & "\setupSasView.exe"
31Global $fRemoteInstallerLocation = "https://jenkins.esss.dk/sasview/job/SasView_Win7_Test/" & $lBuildNumber & "/artifact/sasview/dist/setupSasView.exe"
32Global $fUninstallerLocation = "C:\Program Files (x86)\SasView\unins000.exe"
33Global $lTimeout = 10          ; 10 sec timeout for waiting on windows
34Global $lInstallTimeout = 120  ; 2 min timeout for the installation process
35
36; General globals
37Global $installerPID = 0
38
39
40;; MAIN SCRIPT
41Download()
42Install()
43RunSasView()
44Uninstall()
45
46Exit(0)
47
48;==============================================================
49Func Download()
50   ; Download the file in the background with the selected option of 'force a reload from the remote site.'
51   ConsoleWrite("Downloading...." & @CRLF)
52   Local $iFailFlag = 1
53   Local $hDownload = InetGet($fRemoteInstallerLocation, $fInstallerLocation, $INET_FORCERELOAD)
54
55    ; Close the handle returned by InetGet.
56    InetClose($hDownload)
57        Assert($hDownload, $iFailFlag)
58        ConsoleWrite("Installer downloaded successfully to " & $fInstallerLocation & @CRLF)
59
60EndFunc
61
62Func Install()
63   ;;;;; APPLICATION INSTALLED ;;;;;;;
64   Local $sSetupWindow = "Setup - SasView"
65   Local $iFailFlag = 2
66   ; Run setup
67   if FileExists($fInstallerLocation) Then
68          $installerPID = Run($fInstallerLocation)
69          Assert($installerPID, $iFailFlag)
70          Sleep(1000)
71   Else
72          ;$Error = ObjEvent(AutoIt.Error, "Setup file does not exist","123")
73          Exit($iFailFlag)
74   EndIf
75
76   ; License click through
77   WinActivate($sSetupWindow) ; <-- REQUIRED when connecting from another host
78   Local $test = WinWaitActive($sSetupWindow, "License Agreement", $lTimeout)
79   ;ConsoleWrite("license agreement: " & $test)
80   Assert($test, $iFailFlag)
81   sleep(1000)
82
83   Send("{TAB}{up}{ENTER}")
84
85   ; Location
86   Sleep(1000)
87   $test = WinWaitActive($sSetupWindow, "Select Destination Location", $lTimeout)
88   Assert($test, $iFailFlag)
89   Send("{ENTER}")
90
91   ; Icons, Startup entry
92   Sleep(1000)
93   $test = WinWaitActive($sSetupWindow, "Select Additional Tasks", $lTimeout)
94   Assert($test, $iFailFlag)
95   Send("{ENTER}")
96
97   ; Ready to install...
98   Sleep(1000)
99   $test = WinWaitActive($sSetupWindow, "Ready to Install", $lTimeout)
100   Assert($test, $iFailFlag)
101   Send("{ENTER}")
102
103   ; Final OK on running
104   Sleep(5000)
105   $test = WinWaitActive($sSetupWindow, "Completing the SasView Setup Wizard", $lInstallTimeout)
106   Assert($test, $iFailFlag)
107   Send("{ENTER}")
108   ;ConsoleWrite("Installed" & @CRLF)
109
110EndFunc
111
112
113Func RunSasView()
114   ;;;;; APPLICATION STARTED ;;;;;;;
115   ; Start app - DEBUG ONLY
116   ;;Run("C:\Program Files (x86)\SasView\SasView.exe")
117   Local $iFailFlag = 2
118   ; Wait for the window
119   Sleep(1000)
120   Local $hWnd = WinWaitActive("SasView  - Fitting -", "", $lTimeout)
121   Assert($hWnd, $iFailFlag)
122
123   ;;;;; Load a File
124   ; Open File Load dialog
125   Send("!{f}{ENTER}")
126   WinWaitActive("Choose a file", "", $lTimeout)
127   Assert($hWnd, $iFailFlag)
128   Sleep(200)
129
130   ; Focus is in file chooser - enter filename
131   Send("C:\Program Files (x86)\SasView\test\1d_data\cyl_400_20.txt")
132   Sleep(1000)
133   Send("{ENTER}")
134
135   ;; Send file to fitting
136   ControlClick($hWnd, "Send To", 231)
137
138   ;; Choose a model
139   ControlCommand($hWnd, "", "ComboBox3", "SetCurrentSelection", 1)
140
141   ;; Calculate the model
142   ControlClick($hWnd, "Compute", 211)
143
144   ;; Close SasView
145   WinClose($hWnd)
146
147   Local $hEnd = WinWaitActive("Confirm Exit", "", $lTimeout)
148   Assert($hEnd, $iFailFlag)
149   ControlClick($hEnd, "", "[CLASS:Button; INSTANCE:1]")
150
151   Local $sv_closed = WinWaitClose($hWnd, "", $lTimeout)
152   Assert($sv_closed, $iFailFlag)
153
154EndFunc
155
156Func Uninstall()
157;;;;; UNINSTALL ;;;;;;;
158   Local $iFailFlag = 3
159   $installerPID = Run($fUninstallerLocation)
160   Assert($installerPID, $iFailFlag)
161
162   Local $sSetupWindow = "SasView Uninstall"
163
164   Local $test = WinWaitActive($sSetupWindow, "", $lTimeout)
165   Assert($test, $iFailFlag)
166   Send("{TAB}{ENTER}")
167
168   WinActivate("SasView Uninstal")
169   $test = WinWaitActive($sSetupWindow, "SasView was successfully removed", $lTimeout)
170   Assert($test, $iFailFlag)
171   Send("{ENTER}")
172
173EndFunc
174
175
176;;; HELPER FUNCTIONS ;;;;
177Func Assert($test, $lExitValue)
178   ;;; Asserts $test to be non-zero and exit with code $lExitValue ;;;
179   if $test == 0 Then
180          ProcessClose($installerPID)
181          Exit($lExitValue)
182   EndIf
183EndFunc
Note: See TracBrowser for help on using the repository browser.