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(); 11if opts(2) == "x64" & getos() == "Windows" then 12 arch = "x64/"; 13else 14 arch = ""; 15end 16load("SCI/modules/atoms/macros/atoms_internals/lib"); 17// If previous test did not end properly, restore, else backup config file 18atomsRestoreConfig(%T); 19atomsSaveConfig(); 20// Do not use the autoload system 21atomsSetConfig("autoloadAddAfterInstall","False"); 22atomsSetConfig("Verbose" ,"False"); 23// Load the 1st scenario : See scene1.test.atoms.scilab.org.txt 24// ============================================================================= 25atomsRepositorySetOfl("http://scene1.test.atoms.scilab.org"); 26Scanning repository http://scene1.test.atoms.scilab.org ... Done 27if atomsIsInstalled("toolbox_1") then 28 atomsRemove("toolbox_1"); 29end 30if atomsIsInstalled("toolbox_2") then 31 atomsRemove("toolbox_2"); 32end 33if atomsIsInstalled("toolbox_3") then 34 atomsRemove("toolbox_3"); 35end 36if atomsIsInstalled("toolbox_4") then 37 atomsRemove("toolbox_4"); 38end 39if atomsIsInstalled("toolbox_5") then 40 atomsRemove("toolbox_5"); 41end 42if atomsIsInstalled("toolbox_6") then 43 atomsRemove("toolbox_6"); 44end 45// REMOVING PART 46// REMOVING an Automatic installed toolbox deletes the toolbox it has been 47// installed by 48// ----------------------------------------------------------------------------- 49atomsInstall(["toolbox_5" "1.0"],"user"); 50ref = [ "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" ]; 54if getos()=="Windows" then 55 ref=strsubst(ref,"/","\"); 56end 57removed=atomsRemove(["toolbox_2" "1.0"],"user"); 58[a,b]=gsort(removed(:,1),"r","i"); 59assert_checkequal(removed(b,:),ref); 60// REMOVING an Automatic toolbox deletes all the toolboxes depending on it 61// ----------------------------------------------------------------------------- 62atomsInstall(["toolbox_5" "1.0"],"user"); 63atomsInstall(["toolbox_3" "1.0"],"user"); 64ref = [ "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" ]; 70if getos()=="Windows" then 71 ref=strsubst(ref,"/","\"); 72end 73removed=atomsRemove(["toolbox_1"],"user"); 74[a,b]=gsort(removed(:,1),"r","i"); 75assert_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// ----------------------------------------------------------------------------- 80atomsInstall(["toolbox_5" "1.0"],"user"); 81atomsInstall(["toolbox_3" "1.0"],"user"); 82ref = [ "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" ]; 84if getos()=="Windows" then 85 ref=strsubst(ref,"/","\"); 86end 87removed=atomsRemove(["toolbox_3" "1.0"],"user"); 88[a,b]=gsort(removed(:,1),"r","i"); 89assert_checkequal(removed(b,:),ref); 90// REMOVING a toolbox in a section won't delete it in other sections 91// ----------------------------------------------------------------------------- 92atomsInstall(["toolbox_5" "1.0"],"user"); 93atomsInstall(["toolbox_5" "1.0"],"allusers"); 94ref = [ "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" ]; 98if getos()=="Windows" then 99 ref=strsubst(ref,"/","\"); 100end 101ref_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" ]; 105if getos()=="Windows" then 106 ref_all=strsubst(ref_all,"/","\"); 107end 108removed=atomsRemove(["toolbox_5" "1.0"],"user"); 109[a,b]=gsort(removed(:,1),"r","i"); 110assert_checkequal(removed(b,:),ref); 111removed=atomsRemove(["toolbox_5" "1.0"],"allusers"); 112[a,b]=gsort(removed(:,1),"r","i"); 113assert_checkequal(removed(b,:),ref_all); 114// REMOVING a toolbox with section "all" will remove this toolbox in sections 115// "alluser" AND "user" 116// ----------------------------------------------------------------------------- 117atomsInstall(["toolbox_5" "1.0"],"user"); 118atomsInstall(["toolbox_5" "1.0"],"allusers"); 119ref = [ "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" ]; 127if getos()=="Windows" then 128 ref=strsubst(ref,"/","\"); 129end 130removed=atomsRemove(["toolbox_5" "1.0"],"all"); 131[a,b]=gsort(removed(:,1),"r","i"); 132assert_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// ----------------------------------------------------------------------------- 138atomsInstall(["toolbox_5" "1.0"],"user"); 139ref_empty = []; 140ref = [ "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" ]; 144if getos()=="Windows" then 145 ref=strsubst(ref,"/","\"); 146end 147assert_checkequal(atomsRemove(["toolbox_5" "1.0"],"allusers"),ref_empty); 148removed=atomsRemove(["toolbox_5" "1.0"],"user"); 149[a,b]=gsort(removed(:,1),"r","i"); 150assert_checkequal(removed(b,:),ref); 151// ============================================================================ 152// DELETING PART 153rmdir(atomsPath("install","user")+"archives/","s"); 154mkdir(atomsPath("install","user")+"archives/"); 155rmdir(atomsPath("install","allusers")+"archives/","s"); 156mkdir(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// ----------------------------------------------------------------------------- 161atomsInstall(["toolbox_5" "1.0"],"user"); 162ref = [ "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" ]; 166if getos()=="Windows" then 167 ref=strsubst(ref,"/","\"); 168end 169ref_empty = []; 170removed=atomsRemove(["toolbox_5" "1.0"],"user",%T); 171[a,b]=gsort(removed(:,1),"r","i"); 172assert_checkequal(removed(b,:),ref); 173if getos()=="Windows" then 174 assert_checkequal(ls(atomsPath("install","user")+"archives\"),ref_empty); 175else 176 assert_checkequal(ls(atomsPath("install","user")+"archives/"),ref_empty); 177end 178rmdir(atomsPath("install","user")+"archives/","s"); 179mkdir(atomsPath("install","user")+"archives/"); 180rmdir(atomsPath("install","allusers")+"archives/","s"); 181mkdir(atomsPath("install","allusers")+"archives/"); 182// REMOVING AND DELETING a toolbox will not delete other archives than the ones 183// it depends on 184// ----------------------------------------------------------------------------- 185atomsInstall(["toolbox_5" "1.0"],"user"); 186atomsInstall(["toolbox_6" "1.0"],"user"); 187ref = [ "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(); 191if 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 202elseif 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 212elseif 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"]; 216end 217ref_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" ]; 220if getos()=="Windows" then 221 ref_rem_6=strsubst(ref_rem_6,"/","\"); 222end 223removed=atomsRemove(["toolbox_5" "1.0"],"user",%T); 224[a,b]=gsort(removed(:,1),"r","i"); 225assert_checkequal(removed(b,:),ref); 226left=ls(atomsPath("install","user")+"archives/"); 227[a,b]=gsort(left(:,1),"r","i"); 228assert_checkequal(left(b,:),ref_ls); 229// cleaning 230allremoved=atomsRemove(["toolbox_6" "1.0"],"user",%T); 231[a,b]=gsort(allremoved(:,1),"r","i"); 232assert_checkequal(allremoved(b,:),ref_rem_6); 233//assert_checkequal(atomsRemove(["toolbox_6" "1.0"],"user",%T),ref_rem_6); 234rmdir(atomsPath("install","user")+"archives/","s"); 235mkdir(atomsPath("install","user")+"archives/"); 236rmdir(atomsPath("install","allusers")+"archives/","s"); 237mkdir(atomsPath("install","allusers")+"archives/"); 238// no module should be installed 239assert_checktrue(isempty(atomsGetInstalled())); 240// Restore original values 241// ============================================================================= 242atomsRestoreConfig(%T); 243atomsRepositorySetOfl(mgetl(SCI+"/modules/atoms/tests/unit_tests/repositories.orig")); 244Scanning repository http://atoms.scilab.org/6.0 ... Done 245