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