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