Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Changes In Branch settingsTest Excluding Merge-Ins
This is equivalent to a diff from 401d9b2937 to ca6c8f9be8
2016-08-23
| ||
17:30 | Add extensive tests for the 'settings' and 'unset' commands. Also, add --exact option to the 'settings' / 'unset' commands. ... (check-in: 816bc43b80 user: mistachkin tags: trunk) | |
17:21 | Add a comment. ... (Closed-Leaf check-in: ca6c8f9be8 user: mistachkin tags: settingsTest) | |
10:13 | Fix a harmless but redundant space in the admin_log schema definition. ... (check-in: 1852455158 user: drh tags: trunk) | |
09:49 | eliminate some end-of-line spaces ... (Closed-Leaf check-in: 22ed008469 user: jan.nijtmans tags: mistake) | |
02:19 | Add another test to check the value of each versionable setting after it is written. ... (check-in: 46228ffb1f user: mistachkin tags: settingsTest) | |
02:13 | Add extensive tests for the 'settings' and 'unset' commands. Also, add --exact option to the 'settings' / 'unset' commands. ... (check-in: b9414210cd user: mistachkin tags: settingsTest) | |
01:41 | Better default sort orders for columns on the /uvlist ... (check-in: 401d9b2937 user: drh tags: trunk) | |
01:37 | In the /uvlist, do not link to deleted files. ... (check-in: d8b0489b81 user: drh tags: trunk) | |
Changes to src/db.c.
︙ | ︙ | |||
2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 | ** Defaults to "start" on windows, "open" on Mac, ** and "firefox" on Unix. ** ** Options: ** --global set or unset the given property globally instead of ** setting or unsetting it for the open repository only. ** ** See also: configuration */ void setting_cmd(void){ int i; int globalFlag = find_option("global","g",0)!=0; int unsetFlag = g.argv[1][0]=='u'; db_open_config(1, 0); if( !globalFlag ){ db_find_and_open_repository(OPEN_ANY_SCHEMA | OPEN_OK_NOT_FOUND, 0); } if( !g.repositoryOpen ){ globalFlag = 1; } | > > > > | 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 | ** Defaults to "start" on windows, "open" on Mac, ** and "firefox" on Unix. ** ** Options: ** --global set or unset the given property globally instead of ** setting or unsetting it for the open repository only. ** ** --exact only consider exact name matches. ** ** See also: configuration */ void setting_cmd(void){ int i; int globalFlag = find_option("global","g",0)!=0; int exactFlag = find_option("exact",0,0)!=0; int unsetFlag = g.argv[1][0]=='u'; verify_all_options(); db_open_config(1, 0); if( !globalFlag ){ db_find_and_open_repository(OPEN_ANY_SCHEMA | OPEN_OK_NOT_FOUND, 0); } if( !g.repositoryOpen ){ globalFlag = 1; } |
︙ | ︙ | |||
2914 2915 2916 2917 2918 2919 2920 | if( g.argc==2 ){ for(i=0; aSetting[i].name; i++){ print_setting(&aSetting[i]); } }else if( g.argc==3 || g.argc==4 ){ const char *zName = g.argv[2]; int n = (int)strlen(zName); | | | 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 | if( g.argc==2 ){ for(i=0; aSetting[i].name; i++){ print_setting(&aSetting[i]); } }else if( g.argc==3 || g.argc==4 ){ const char *zName = g.argv[2]; int n = (int)strlen(zName); const Setting *pSetting = db_find_setting(zName, !exactFlag); if( pSetting==0 ){ fossil_fatal("no such setting: %s", zName); } if( globalFlag && fossil_strcmp(pSetting->name, "manifest")==0 ){ fossil_fatal("cannot set 'manifest' globally"); } if( unsetFlag || g.argc==4 ){ |
︙ | ︙ | |||
2947 2948 2949 2950 2951 2952 2953 | }else{ db_set(pSetting->name, g.argv[3], globalFlag); } if( isManifest && g.localOpen ){ manifest_to_disk(db_lget_int("checkout", 0)); } }else{ | | > > > > > | 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 | }else{ db_set(pSetting->name, g.argv[3], globalFlag); } if( isManifest && g.localOpen ){ manifest_to_disk(db_lget_int("checkout", 0)); } }else{ while( pSetting->name ){ if( exactFlag ){ if( fossil_strcmp(pSetting->name,zName)!=0 ) break; }else{ if( fossil_strncmp(pSetting->name,zName,n)!=0 ) break; } print_setting(pSetting); pSetting++; } } }else{ usage("?PROPERTY? ?VALUE? ?-global?"); } |
︙ | ︙ |
Added test/settings-repo.test.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 | # # Copyright (c) 2016 D. Richard Hipp # # This program is free software; you can redistribute it and/or # modify it under the terms of the Simplified BSD License (also # known as the "2-Clause License" or "FreeBSD License".) # # This program is distributed in the hope that it will be useful, # but without any warranty; without even the implied warranty of # merchantability or fitness for a particular purpose. # # Author contact information: # drh@hwaci.com # http://www.hwaci.com/drh/ # ############################################################################ # # The "settings" and "unset" commands that may modify the repository. # require_no_open_checkout set dir [file dirname [info script]]; test_setup ############################################################################### # # Complete syntax as tested: # # fossil settings ?PROPERTY? ?VALUE? ?OPTIONS? # fossil unset PROPERTY ?OPTIONS? # # Where the only supported options are "--global" and "--exact". # ############################################################################### set all_settings [get_all_settings] foreach name $all_settings { # # HACK: Make 100% sure that there are no non-default setting values # present anywhere. # fossil unset $name --exact --global fossil unset $name --exact # # NOTE: Query for the hard-coded default value of this setting and # save it. # fossil test-th-eval "setting $name" set defaults($name) [normalize_result] } ############################################################################### fossil settings bad-setting some_value test settings-set-bad-local { [normalize_result] eq "no such setting: bad-setting" } fossil settings bad-setting some_value --global test settings-set-bad-global { [normalize_result] eq "no such setting: bad-setting" } ############################################################################### fossil unset bad-setting test settings-unset-bad-local { [normalize_result] eq "no such setting: bad-setting" } fossil unset bad-setting --global test settings-unset-bad-global { [normalize_result] eq "no such setting: bad-setting" } ############################################################################### fossil settings ssl some_value test settings-set-ambiguous-local { [normalize_result] eq "ambiguous setting \"ssl\" - might be: ssl-ca-location ssl-identity" } fossil settings ssl some_value --global test settings-set-ambiguous-global { [normalize_result] eq "ambiguous setting \"ssl\" - might be: ssl-ca-location ssl-identity" } ############################################################################### fossil unset ssl test settings-unset-ambiguous-local { [normalize_result] eq "ambiguous setting \"ssl\" - might be: ssl-ca-location ssl-identity" } fossil unset ssl --global test settings-unset-ambiguous-global { [normalize_result] eq "ambiguous setting \"ssl\" - might be: ssl-ca-location ssl-identity" } ############################################################################### set pattern(1) {^%name%$} set pattern(3) {^%name%[ ]+\(global\)[ ]+%value%+$} set pattern(4) {^%name%[ ]+\(local\)[ ]+%value%+$} foreach name $all_settings { if {$name ne "manifest"} { set value #global_for_$name fossil settings $name $value --exact --global set data [normalize_result] test settings-set-$name-global { $data eq "" } fossil settings $name --exact --global set data [normalize_result] test settings-set-check1-$name-global { [regexp -- [string map \ [list %name% $name %value% $value] $pattern(3)] $data] } fossil test-th-eval --open-config "setting $name" set data [normalize_result] test settings-set-check2-$name-global { $data eq $value } fossil unset $name --exact --global set data [normalize_result] test settings-unset-$name-global { $data eq "" } fossil settings $name --exact --global set data [normalize_result] test settings-unset-check1-$name-global { [regexp -- [string map \ [list %name% $name %value% $value] $pattern(1)] $data] } fossil test-th-eval --open-config "setting $name" set data [normalize_result] test settings-unset-check2-$name-global { $data eq $defaults($name) } } set value #local_for_$name fossil settings $name $value --exact set data [normalize_result] test settings-set-$name-local { $data eq "" } fossil settings $name --exact set data [normalize_result] test settings-set-check1-$name-local { [regexp -- [string map \ [list %name% $name %value% $value] $pattern(4)] $data] } fossil test-th-eval --open-config "setting $name" set data [normalize_result] test settings-set-check2-$name-local { $data eq $value } fossil unset $name --exact set data [normalize_result] test settings-unset-$name-local { $data eq "" } fossil settings $name --exact set data [normalize_result] test settings-unset-check1-$name-local { [regexp -- [string map \ [list %name% $name %value% $value] $pattern(1)] $data] } fossil test-th-eval --open-config "setting $name" set data [normalize_result] test settings-unset-check2-$name-local { $data eq $defaults($name) } } ############################################################################### set pattern(5) \ {^%name%[ ]+\n \(overridden by contents of file \.fossil-settings/%name%\)$} set versionable_settings [get_versionable_settings] file mkdir .fossil-settings foreach name $versionable_settings { fossil settings $name --exact set data [normalize_result] test settings-before-versionable-$name { [regexp -- [string map [list %name% $name] $pattern(1)] $data] } set value #versionable_for_$name set fileName [file join .fossil-settings $name] write_file $fileName $value fossil settings $name --exact set data [normalize_result] test settings-set-check1-versionable-$name { [regexp -- [string map [list %name% $name] $pattern(5)] $data] } fossil test-th-eval --open-config "setting $name" set data [normalize_result] test settings-set-check2-versionable-$name { $data eq $value } file delete $fileName fossil settings $name --exact set data [normalize_result] test settings-after-versionable-$name { [regexp -- [string map [list %name% $name] $pattern(1)] $data] } } ############################################################################### test_cleanup |
Added test/settings.test.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | # # Copyright (c) 2016 D. Richard Hipp # # This program is free software; you can redistribute it and/or # modify it under the terms of the Simplified BSD License (also # known as the "2-Clause License" or "FreeBSD License".) # # This program is distributed in the hope that it will be useful, # but without any warranty; without even the implied warranty of # merchantability or fitness for a particular purpose. # # Author contact information: # drh@hwaci.com # http://www.hwaci.com/drh/ # ############################################################################ # # The "settings" and "unset" commands. # set dir [file dirname [info script]]; test_setup ############################################################################### # # Complete syntax as tested: # # fossil settings ?PROPERTY? ?VALUE? ?OPTIONS? # fossil unset PROPERTY ?OPTIONS? # # Where the only supported options are "--global" and "--exact". # ############################################################################### # # NOTE: The [extract_setting_names] procedure extracts the list of setting # names from the line-ending normalized output of the "fossil settings" # command. It assumes that a setting name must begin with a lowercase # letter. It also assumes that any output lines that start with a # lowercase letter contain a setting name starting at that same point. # proc extract_setting_names { data } { set names [list] foreach {dummy name} [regexp \ -all -line -inline -- {^([a-z][a-z0-9\-]*) } $data] { lappend names $name } return $names } ############################################################################### set all_settings [get_all_settings] fossil settings set local_settings [extract_setting_names [normalize_result_no_trim]] fossil settings --global set global_settings [extract_setting_names [normalize_result_no_trim]] foreach name $all_settings { test settings-have-local-$name { [lsearch -exact $local_settings $name] != -1 } test settings-have-global-$name { [lsearch -exact $global_settings $name] != -1 } } foreach name $local_settings { test settings-valid-local-$name { [lsearch -exact $all_settings $name] != -1 } } foreach name $global_settings { test settings-valid-global-$name { [lsearch -exact $all_settings $name] != -1 } } ############################################################################### set pattern(1) {^%name%$} set pattern(2) {^%name%[ ]+\((?:local|global)\)[ ]+[^ ]+$} foreach name $all_settings { fossil settings $name --exact set data [normalize_result] test settings-query-local-$name { [regexp -- [string map [list %name% $name] $pattern(1)] $data] || [regexp -- [string map [list %name% $name] $pattern(2)] $data] } fossil settings $name --exact --global set data [normalize_result] if {$name eq "manifest"} { test settings-query-global-$name { $data eq "cannot set 'manifest' globally" } } else { test settings-query-global-$name { [regexp -- [string map [list %name% $name] $pattern(1)] $data] || [regexp -- [string map [list %name% $name] $pattern(2)] $data] } } } ############################################################################### fossil settings bad-setting test settings-query-bad-local { [normalize_result] eq "no such setting: bad-setting" } fossil settings bad-setting --global test settings-query-bad-global { [normalize_result] eq "no such setting: bad-setting" } ############################################################################### test_cleanup |
Changes to test/tester.tcl.
︙ | ︙ | |||
184 185 186 187 188 189 190 191 192 193 194 195 196 197 | fconfigure $out -translation binary puts -nonewline $out $txt close $out } proc write_file_indented {filename txt} { write_file $filename [string trim [string map [list "\n " \n] $txt]]\n } # Return true if two files are the same # proc same_file {a b} { set x [read_file $a] regsub -all { +\n} $x \n x set y [read_file $b] | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 | fconfigure $out -translation binary puts -nonewline $out $txt close $out } proc write_file_indented {filename txt} { write_file $filename [string trim [string map [list "\n " \n] $txt]]\n } # Returns the list of all supported versionable settings. # proc get_versionable_settings {} { # # TODO: If the list of supported versionable settings in "db.c" is modified, # this list (and procedure) most likely needs to be modified as well. # set result [list \ allow-symlinks \ binary-glob \ clean-glob \ crnl-glob \ dotfiles \ empty-dirs \ encoding-glob \ ignore-glob \ keep-glob \ manifest \ th1-setup \ th1-uri-regexp] fossil test-th-eval "hasfeature tcl" if {$::RESULT eq "1"} { lappend result tcl-setup } return $result } # Returns the list of all supported settings. # proc get_all_settings {} { # # TODO: If the list of supported settings in "db.c" is modified, this list # (and procedure) most likely needs to be modified as well. # set result [list \ access-log \ admin-log \ allow-symlinks \ auto-captcha \ auto-hyperlink \ auto-shun \ autosync \ autosync-tries \ binary-glob \ case-sensitive \ clean-glob \ clearsign \ crnl-glob \ default-perms \ diff-binary \ diff-command \ dont-push \ dotfiles \ editor \ empty-dirs \ encoding-glob \ exec-rel-paths \ gdiff-command \ gmerge-command \ hash-digits \ http-port \ https-login \ ignore-glob \ keep-glob \ localauth \ main-branch \ manifest \ max-loadavg \ max-upload \ mtime-changes \ pgp-command \ proxy \ relative-paths \ repo-cksum \ self-register \ ssh-command \ ssl-ca-location \ ssl-identity \ th1-setup \ th1-uri-regexp \ web-browser] fossil test-th-eval "hasfeature legacyMvRm" if {$::RESULT eq "1"} { lappend result mv-rm-files } fossil test-th-eval "hasfeature tcl" if {$::RESULT eq "1"} { lappend result tcl tcl-setup } fossil test-th-eval "hasfeature th1Docs" if {$::RESULT eq "1"} { lappend result th1-docs } fossil test-th-eval "hasfeature th1Hooks" if {$::RESULT eq "1"} { lappend result th1-hooks } return [lsort -dictionary $result] } # Return true if two files are the same # proc same_file {a b} { set x [read_file $a] regsub -all { +\n} $x \n x set y [read_file $b] |
︙ | ︙ | |||
653 654 655 656 657 658 659 660 661 662 663 664 665 666 | return [incr seqNo] } # fixup the whitespace in the result to make it easier to compare. proc normalize_result {} { return [string map [list \r\n \n] [string trim $::RESULT]] } # returns the first line of the normalized result. proc first_data_line {} { return [lindex [split [normalize_result] \n] 0] } # returns the second line of the normalized result. | > > > > > | 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 | return [incr seqNo] } # fixup the whitespace in the result to make it easier to compare. proc normalize_result {} { return [string map [list \r\n \n] [string trim $::RESULT]] } # fixup the line-endings in the result to make it easier to compare. proc normalize_result_no_trim {} { return [string map [list \r\n \n] $::RESULT] } # returns the first line of the normalized result. proc first_data_line {} { return [lindex [split [normalize_result] \n] 0] } # returns the second line of the normalized result. |
︙ | ︙ |