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