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