bug fix 8648 - delete the tarball when uninstalling
[scilab.git] / scilab / modules / atoms / tests / unit_tests / atomsRemove.dia.ref
1 // =============================================================================
2 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 // Copyright (C) 2011 - DIGITEO - Simon GARESTE <simon.gareste@scilab.org>
4 //
5 //  This file is distributed under the same license as the Scilab package.
6 // =============================================================================
7 // <-- JVM NOT MANDATORY -->
8 load("SCI/modules/atoms/macros/atoms_internals/lib");
9 // Do not use the autoload system
10 config_autoload = atomsGetConfig("autoloadAddAfterInstall");
11 config_Verbose  = atomsGetConfig("Verbose");
12 atomsSetConfig("autoloadAddAfterInstall","False");
13 atomsSetConfig("Verbose" ,"False");
14 // Load the 1st scenario : See scene1.test.atoms.scilab.org.txt
15 // =============================================================================
16 atomsRepositorySetOfl("http://scene1.test.atoms.scilab.org");
17 if atomsIsInstalled("toolbox_1") then
18     atomsRemove("toolbox_1");
19 end
20 if atomsIsInstalled("toolbox_2") then
21     atomsRemove("toolbox_2");
22 end
23 if atomsIsInstalled("toolbox_3") then
24     atomsRemove("toolbox_3");
25 end
26 if atomsIsInstalled("toolbox_4") then
27     atomsRemove("toolbox_4");
28 end
29 if atomsIsInstalled("toolbox_5") then
30     atomsRemove("toolbox_5");
31 end
32 if atomsIsInstalled("toolbox_6") then
33     atomsRemove("toolbox_6");
34 end
35 // REMOVING PART
36 // REMOVING an Automatic installed toolbox deletes the toolbox it has been 
37 // installed by
38 // -----------------------------------------------------------------------------
39 atomsInstall(["toolbox_5" "1.0"],"user");
40 ref = [ "toolbox_1"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_1/1.0-1"  "A" ;
41         "toolbox_2"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_2/1.0-1"  "A" ;
42         "toolbox_4"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_4/1.0-1"  "A" ;
43         "toolbox_5"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_5/1.0-1"  "I" ];
44 if getos()=="Windows" then
45    ref=strsubst(ref,"/","\");
46 end
47 removed=atomsRemove(["toolbox_2" "1.0"],"user");
48 [a,b]=gsort(removed(:,1),'r','i');
49 assert_checkequal(removed(b,:),ref);
50 // REMOVING an Automatic toolbox deletes all the toolboxes depending on it
51 // -----------------------------------------------------------------------------
52 atomsInstall(["toolbox_5" "1.0"],"user");
53 atomsInstall(["toolbox_3" "1.0"],"user");
54 ref = [ "toolbox_1"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_1/1.0-1"  "A" ;
55         "toolbox_2"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_2/1.0-1"  "A" ;
56         "toolbox_2"  "2.0-1"  "user"  "SCIHOME/atoms/toolbox_2/2.0-1"  "A" ;
57         "toolbox_3"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_3/1.0-1"  "I" ;
58         "toolbox_4"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_4/1.0-1"  "A" ;
59         "toolbox_5"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_5/1.0-1"  "I" ];
60 if getos()=="Windows" then
61    ref=strsubst(ref,"/","\");
62 end
63 removed=atomsRemove(["toolbox_1"],"user");
64 [a,b]=gsort(removed(:,1),'r','i');
65 assert_checkequal(removed(b,:),ref);
66 //assert_checkequal(atomsRemove(["toolbox_1"]      ,"user"),ref);
67 // REMOVING an Intentionnaly installed toolbox won't delete an Automatically
68 // installed toolbox if it is needed by another toolbox
69 // -----------------------------------------------------------------------------
70 atomsInstall(["toolbox_5" "1.0"],"user");
71 atomsInstall(["toolbox_3" "1.0"],"user");
72 ref = [ "toolbox_2"  "2.0-1"  "user"  "SCIHOME/atoms/toolbox_2/2.0-1"  "A" ;
73         "toolbox_3"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_3/1.0-1"  "I" ];
74 if getos()=="Windows" then
75    ref=strsubst(ref,"/","\");
76 end
77 removed=atomsRemove(["toolbox_3" "1.0"],"user");
78 [a,b]=gsort(removed(:,1),'r','i');
79 assert_checkequal(removed(b,:),ref);
80 // REMOVING a toolbox in a section won't delete it in other sections
81 // -----------------------------------------------------------------------------
82 atomsInstall(["toolbox_5" "1.0"],"user");
83 atomsInstall(["toolbox_5" "1.0"],"allusers");
84 ref = [ "toolbox_1"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_1/1.0-1"  "A" ;
85         "toolbox_2"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_2/1.0-1"  "A" ;
86         "toolbox_4"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_4/1.0-1"  "A" ;
87         "toolbox_5"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_5/1.0-1"  "I" ];
88 if getos()=="Windows" then
89    ref=strsubst(ref,"/","\");
90 end
91 ref_all = [ "toolbox_1"  "1.0-1"  "allusers"  "SCI/contrib/toolbox_1/1.0-1"  "A" ;
92             "toolbox_2"  "1.0-1"  "allusers"  "SCI/contrib/toolbox_2/1.0-1"  "A" ;
93             "toolbox_4"  "1.0-1"  "allusers"  "SCI/contrib/toolbox_4/1.0-1"  "A" ;
94             "toolbox_5"  "1.0-1"  "allusers"  "SCI/contrib/toolbox_5/1.0-1"  "I" ];
95 if getos()=="Windows" then
96    ref_all=strsubst(ref_all,"/","\");
97 end
98 removed=atomsRemove(["toolbox_5" "1.0"],"user");
99 [a,b]=gsort(removed(:,1),'r','i');
100 assert_checkequal(removed(b,:),ref);
101 removed=atomsRemove(["toolbox_5" "1.0"],"allusers");
102 [a,b]=gsort(removed(:,1),'r','i');
103 assert_checkequal(removed(b,:),ref_all);
104 // REMOVING a toolbox with section "all" will remove this toolbox in sections 
105 // "alluser" AND "user"
106 // -----------------------------------------------------------------------------
107 atomsInstall(["toolbox_5" "1.0"],"user");
108 atomsInstall(["toolbox_5" "1.0"],"allusers");
109 ref = [ "toolbox_1"  "1.0-1"  "allusers"  "SCI/contrib/toolbox_1/1.0-1"  "A" ;
110         "toolbox_1"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_1/1.0-1"  "A" ;
111         "toolbox_2"  "1.0-1"  "allusers"  "SCI/contrib/toolbox_2/1.0-1"  "A" ;
112         "toolbox_2"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_2/1.0-1"  "A" ;
113         "toolbox_4"  "1.0-1"  "allusers"  "SCI/contrib/toolbox_4/1.0-1"  "A" ;
114         "toolbox_4"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_4/1.0-1"  "A" ;
115         "toolbox_5"  "1.0-1"  "allusers"  "SCI/contrib/toolbox_5/1.0-1"  "I" ;
116         "toolbox_5"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_5/1.0-1"  "I" ];
117 if getos()=="Windows" then
118    ref=strsubst(ref,"/","\");
119 end
120 removed=atomsRemove(["toolbox_5" "1.0"],"all");
121 [a,b]=gsort(removed(:,1),'r','i');
122 assert_checkequal(removed(b,:),ref);
123 // REMOVING a toolbox from a section where it doesn't exist won't remove it from
124 // its existing section
125 // REMOVING an Intentionnaly installed toolbox deletes all the Automatically
126 // installed toolbox that were installed for this.
127 // -----------------------------------------------------------------------------
128 atomsInstall(["toolbox_5" "1.0"],"user");
129 ref_empty = [];
130 ref = [ "toolbox_1"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_1/1.0-1"  "A" ;
131         "toolbox_2"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_2/1.0-1"  "A" ;
132         "toolbox_4"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_4/1.0-1"  "A" ;
133         "toolbox_5"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_5/1.0-1"  "I" ];
134 if getos()=="Windows" then
135    ref=strsubst(ref,"/","\");
136 end
137 assert_checkequal(atomsRemove(["toolbox_5" "1.0"],"allusers"),ref_empty);
138 removed=atomsRemove(["toolbox_5" "1.0"],"user");
139 [a,b]=gsort(removed(:,1),'r','i');
140 assert_checkequal(removed(b,:),ref);
141 // ============================================================================
142 // DELETING PART
143 rmdir(SCIHOME+"/atoms/archives/",'s');
144 mkdir(SCIHOME+"/atoms/archives");
145 rmdir(SCI+"/contrib/archives/",'s');
146 mkdir(SCI+"/contrib/archives");
147 // ============================================================================
148 // REMOVING AND DELETING a toolbox will delete its archives and archives of the
149 // toolboxes it depends on
150 // -----------------------------------------------------------------------------
151 atomsInstall(["toolbox_5" "1.0"],"user");
152 ref = [ "toolbox_1"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_1/1.0-1"  "A" ;
153         "toolbox_2"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_2/1.0-1"  "A" ;
154         "toolbox_4"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_4/1.0-1"  "A" ;
155         "toolbox_5"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_5/1.0-1"  "I" ];
156 if getos()=="Windows" then
157    ref=strsubst(ref,"/","\");
158 end
159 ref_empty = [];
160 removed=atomsRemove(["toolbox_5" "1.0"],"user",%T);
161 [a,b]=gsort(removed(:,1),'r','i');
162 assert_checkequal(removed(b,:),ref);
163 if getos()=="Windows" then
164     assert_checkequal(ls(atomsPath("install","user")+'archives\'),ref_empty);
165 else
166     assert_checkequal(ls(atomsPath("install","user")+'archives/'),ref_empty);
167 end
168 rmdir(SCIHOME+"/atoms/archives/",'s');
169 mkdir(SCIHOME+"/atoms/archives");
170 rmdir(SCI+"/contrib/archives/",'s');
171 mkdir(SCI+"/contrib/archives");
172 // REMOVING AND DELETING a toolbox will not delete other archives than the ones
173 // it depends on
174 // -----------------------------------------------------------------------------
175 atomsInstall(["toolbox_5" "1.0"],"user");
176 atomsInstall(["toolbox_6" "1.0"],"user");
177 ref = [ "toolbox_2"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_2/1.0-1"  "A" ;
178         "toolbox_4"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_4/1.0-1"  "A" ;
179         "toolbox_5"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_5/1.0-1"  "I" ];
180 [version, opts] = getversion();
181 arch = opts(2);
182 if getos()=="Windows" then
183     ref=strsubst(ref,"/","\");
184         if arch == "x86" then
185 ref_ls = [ "toolbox_1_1.0-1.bin.windows.zip";
186            "toolbox_2_2.0-1.bin.windows.zip";
187            "toolbox_6_1.0-1.bin.windows.zip"];
188         else
189 ref_ls = [ "toolbox_1_1.0-1.bin.x64.windows.zip";
190            "toolbox_2_2.0-1.bin.x64.windows.zip";
191            "toolbox_6_1.0-1.bin.x64.windows.zip"];
192         end
193 elseif getos()=="Linux" then
194         if arch == "x86" then
195 ref_ls = [ "toolbox_1_1.0-1.bin.i686.linux.tar.gz";
196            "toolbox_2_2.0-1.bin.i686.linux.tar.gz";
197            "toolbox_6_1.0-1.bin.i686.linux.tar.gz"];    
198         else
199 ref_ls = [ "toolbox_1_1.0-1.bin.x86_64.linux.tar.gz";
200            "toolbox_2_2.0-1.bin.x86_64.linux.tar.gz";
201            "toolbox_6_1.0-1.bin.x86_64.linux.tar.gz"];  
202         end
203 elseif getos()=="Darwin" then
204 ref_ls = [ "toolbox_1_1.0-1.bin.x86_64.darwin.tar.gz";
205            "toolbox_2_2.0-1.bin.x86_64.darwin.tar.gz";
206            "toolbox_6_1.0-1.bin.x86_64.darwin.tar.gz"]; 
207 end
208 ref_rem_6 = [ "toolbox_1"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_1/1.0-1"  "A" ;
209               "toolbox_2"  "2.0-1"  "user"  "SCIHOME/atoms/toolbox_2/2.0-1"  "A" ;
210               "toolbox_6"  "1.0-1"  "user"  "SCIHOME/atoms/toolbox_6/1.0-1"  "I" ];
211 if getos()=="Windows" then
212    ref_rem_6=strsubst(ref_rem_6,"/","\");
213 end
214 removed=atomsRemove(["toolbox_5" "1.0"],"user",%T);
215 [a,b]=gsort(removed(:,1),'r','i');
216 assert_checkequal(removed(b,:),ref);
217 left=ls(atomsPath("install","user")+'archives/');
218 [a,b]=gsort(left(:,1),'r','i');
219 assert_checkequal(left(b,:),ref_ls);
220 // cleaning
221 allremoved=atomsRemove(["toolbox_6" "1.0"],"user",%T);
222 [a,b]=gsort(allremoved(:,1),'r','i');
223 assert_checkequal(allremoved(b,:),ref_rem_6);
224 rmdir(atomsPath("install","user")+'archives/','s');
225 mkdir(atomsPath("install","user")+'archives/');
226 rmdir(atomsPath("install","allusers")+'archives/','s');
227 mkdir(atomsPath("install","allusers")+'archives/');
228 // no module should be installed
229 assert_checktrue(isempty(atomsGetInstalled()));
230 // Restore original values
231 // =============================================================================
232 atomsSetConfig("autoloadAddAfterInstall",config_autoload);
233 atomsSetConfig("Verbose" ,config_Verbose);
234 atomsRepositorySetOfl(mgetl(SCI+"/modules/atoms/tests/unit_tests/repositories.orig"));