source: trunk/base/src/port1.0/tests/portutil.tcl @ 42662

Last change on this file since 42662 was 42662, checked in by raimue@…, 12 years ago

Merged revisions 34469,34852,34854-34855,34900,36952-36956,37507-37508,37511-37512,41040,41042-41046,41138-41139,41142-41143,41145,41151,41403,41458,41462-41463,42575,42626,42640-42641,42659 via svnmerge from
https://svn.macosforge.org/repository/macports/branches/variant-descs-14482/base

........

r34469 | raimue@… | 2008-02-26 07:08:09 +0100 (Tue, 26 Feb 2008) | 3 lines


port/port.tcl:
Reading from .config/variant_descriptions actually works

........

r34852 | raimue@… | 2008-03-09 02:45:22 +0100 (Sun, 09 Mar 2008) | 4 lines


macports1.0/macports.tcl:
New API: macports::getsourceconfigdir
Returns the path to .config for a porturl.

........

r34854 | raimue@… | 2008-03-09 03:11:27 +0100 (Sun, 09 Mar 2008) | 3 lines


port/port.tcl:
Use new API macports::getsourceconfigdir

........

r34855 | raimue@… | 2008-03-09 03:12:54 +0100 (Sun, 09 Mar 2008) | 3 lines


port/port.tcl:
Treat variant descriptions as strings to avoid problems with braces

........

r34900 | raimue@… | 2008-03-10 16:54:25 +0100 (Mon, 10 Mar 2008) | 3 lines


port/port.tcl:
Rename variable

........

r36952 | raimue@… | 2008-05-21 04:20:27 +0200 (Wed, 21 May 2008) | 3 lines


port/port.tcl:
Remove get_variant_desc, this will now be done in port1.0/portutil.tcl instead

........

r36953 | raimue@… | 2008-05-21 04:22:04 +0200 (Wed, 21 May 2008) | 3 lines


macports1.0/macports.tcl:
Give the worker access to variable porturl and proc getsourceconfigdir

........

r36954 | raimue@… | 2008-05-21 04:23:37 +0200 (Wed, 21 May 2008) | 3 lines


port1.0/tests:
Fix the portutil test after r36953

........

r36955 | raimue@… | 2008-05-21 05:01:11 +0200 (Wed, 21 May 2008) | 3 lines


macports1.0/macports.tcl:
Give worker access to getprotocol and getportdir as they are needed for getsourceconfigdir

........

r36956 | raimue@… | 2008-05-21 05:02:23 +0200 (Wed, 21 May 2008) | 3 lines


port1.0/portutil.tcl:
New proc variant_desc, reads global variant description file

........

r37507 | raimue@… | 2008-06-10 16:04:54 +0200 (Tue, 10 Jun 2008) | 4 lines


port1.0/portutil.tcl:
Don't warn about a missing description if it is set global,
but warn if the variant overrides the global description

........

r37508 | raimue@… | 2008-06-10 16:14:03 +0200 (Tue, 10 Jun 2008) | 3 lines


macports1.0/macports.tcl:
Use .resources instead of .config as it is a bit clearer, see #14553

........

r37511 | raimue@… | 2008-06-10 17:22:12 +0200 (Tue, 10 Jun 2008) | 5 lines


port1.0/portutil.tcl:
Switch back to this format:
name {description}
So this could be easily extended if ever needed.

........

r37512 | raimue@… | 2008-06-10 17:27:48 +0200 (Tue, 10 Jun 2008) | 3 lines


port1.0/portutil.tcl:
Add a warning if global variant description file could not be opened

........

r41040 | raimue@… | 2008-10-21 13:06:39 +0200 (Tue, 21 Oct 2008) | 4 lines


macports/macport.tcl:

  • New flag "default" for sources to indicate fallback for resources (group)
  • Add parameter to getsourceconfigdir to get path for a requested file

........

r41042 | raimue@… | 2008-10-21 13:11:44 +0200 (Tue, 21 Oct 2008) | 3 lines


macports1.0/macports.tcl:
Rename getsourceconfigdir to getportresourcepath

........

r41043 | raimue@… | 2008-10-21 13:15:16 +0200 (Tue, 21 Oct 2008) | 3 lines


port1.0/portutil.tcl:
Use getportresourcepath for the group files

........

r41044 | raimue@… | 2008-10-21 13:19:47 +0200 (Tue, 21 Oct 2008) | 3 lines


port1.0/portlint.tcl:
Use getresourcepath for group files

........

r41045 | raimue@… | 2008-10-21 13:20:36 +0200 (Tue, 21 Oct 2008) | 3 lines


port1.0/portmain.tcl:
Add a note that we should get rid of $portresourcepath in favor of [getportresourcepath]

........

r41046 | raimue@… | 2008-10-21 13:40:29 +0200 (Tue, 21 Oct 2008) | 3 lines


port1.0/portutil.tcl:
Missed one instance of getsourceconfigdir

........

r41138 | raimue@… | 2008-10-25 20:52:50 +0200 (Sat, 25 Oct 2008) | 3 lines


port1.0/portutil.tcl:
Use getportresourcepath for global variant descriptions

........

r41139 | raimue@… | 2008-10-25 21:23:15 +0200 (Sat, 25 Oct 2008) | 3 lines


port1.0/portmain.tcl:
Correct XXX tag

........

r41142 | raimue@… | 2008-10-25 23:11:30 +0200 (Sat, 25 Oct 2008) | 3 lines


port1.0/portfetch.tcl:
Use getportresourcepath

........

r41143 | raimue@… | 2008-10-25 23:12:04 +0200 (Sat, 25 Oct 2008) | 3 lines


port1.0/portdestroot.tcl:
Use getportresourcepath

........

r41145 | raimue@… | 2008-10-26 00:04:15 +0200 (Sun, 26 Oct 2008) | 3 lines


macports1.0/macports.tcl:
Fix a problem with URLs not using the file protocol

........

r41151 | raimue@… | 2008-10-26 03:09:54 +0100 (Sun, 26 Oct 2008) | 3 lines


macports1.0/macports.tcl:
Fix issues introduced in r41145, the file exists check was wrong

........

r41403 | raimue@… | 2008-11-01 22:59:21 +0100 (Sat, 01 Nov 2008) | 3 lines


port1.0/portutil.tcl:
Add a debug output which group files are used

........

r41458 | blb@… | 2008-11-03 22:58:28 +0100 (Mon, 03 Nov 2008) | 2 lines


Add [default] tag and description to sources.conf

........

r41462 | blb@… | 2008-11-04 02:12:28 +0100 (Tue, 04 Nov 2008) | 2 lines


No longer need to install resources with base

........

r41463 | blb@… | 2008-11-04 02:14:49 +0100 (Tue, 04 Nov 2008) | 4 lines


Move the install/ subdir (containing the mtree files) into .../share/macports
from the resources dir (the mtree contains a bit of install-time info, so it
shouldn't be with the resources stuff in the port tree)

........

r42575 | blb@… | 2008-11-25 01:53:05 +0100 (Tue, 25 Nov 2008) | 3 lines


Add script to handle upgrades through configure/make/make install and
the package, so [default] is added as appropriate to sources.conf

........

r42626 | raimue@… | 2008-11-27 02:21:15 +0100 (Thu, 27 Nov 2008) | 3 lines


package1.0/portpkg.tcl, package1.0/portmpkg.tcl:
Remove portresourcepath and use [getportresourcepath] instead

........

r42640 | raimue@… | 2008-11-27 11:49:32 +0100 (Thu, 27 Nov 2008) | 3 lines


package1.0/portrpm.tcl, package1.0/portsrpm.tcl:
Remove reference to portresurcepath which is not used at all

........

r42641 | raimue@… | 2008-11-27 11:52:12 +0100 (Thu, 27 Nov 2008) | 3 lines


port1.0/portmain.tcl:
Remove definition of portresourcepath as it is not used any more

........

r42659 | raimue@… | 2008-11-28 16:44:30 +0100 (Fri, 28 Nov 2008) | 3 lines


macports1.0/macports.tcl:
Rename portresourcepath from .resources to _resources

........

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 6.9 KB
Line 
1# Test file for Pextlib's fs-traverse
2# Requires r/w access to /tmp
3# MacPorts must be installed for this to work
4
5package require macports
6mportinit
7
8# load the current copy of portutil instead of the installed one
9source [file dirname [info script]]/../portutil.tcl
10
11# end boilerplate
12
13namespace eval tests {
14
15proc test_delete {} {
16    set root "/tmp/macports-portutil-delete"
17    # use file delete -force to kill the test directory if it already exists
18    # yeah I realize this will fail on 10.3 if it already exists. oh well.
19    file delete -force $root
20   
21    try {
22        mtree $root {
23            a               directory
24            a/a             file
25            a/b             file
26            a/c             directory
27            a/c/a           file
28            a/c/b           {link ../b}
29            a/c/c           {link ../../b}
30            a/c/d           directory
31            a/c/d/a         file
32            a/c/d/b         directory
33            a/c/d/c         file
34            a/d             file
35            b               directory
36            b/a             file
37            b/b             {link q}
38            b/c             directory
39            b/c/a           file
40            b/c/b           file
41            b/d             file
42        }
43       
44        # test deleting a symlink
45        delete $root/a/c/b
46       
47        if {[file exists $root/a/c/b] || ![file exists $root/a/b]} {
48            error "delete (symlink) failed"
49        }
50       
51        # test multiple args
52        delete $root/a $root/b
53       
54        if {[file exists $root/a] || [file exists $root/b]} {
55            error "delete (multiple args) failed"
56        }
57    } finally {
58        file delete -force $root
59    }
60}
61
62proc test_depends_lib-delete {} {
63    # tests depends_lib-delete
64    # actually tests all option-deletes
65    # but the bug was originally documented with depends_lib
66   
67    # depends_lib is intended to work from within a worker thread
68    # so we shall oblige
69    set workername [interp create]
70    macports::worker_init $workername {} {} [macports::getportbuildpath {}] {} {}
71    $workername alias scriptname info script
72    set body {
73        # load the current copy of portutil instead of the installed one
74        source [file dirname [scriptname]]/../portutil.tcl
75        package require port
76       
77        depends_lib port:foo port:bar port:blah
78        depends_lib-delete port:blah port:bar
79        array get PortInfo
80    }
81    if {[catch {$workername eval $body} result]} {
82        interp delete $workername
83        error $result $::errorInfo $::errorCode
84    } else {
85        interp delete $workername
86    }
87    array set temp $result
88    if {$temp(depends_lib) ne "port:foo"} {
89        error "depends_lib-delete did not delete properly"
90    }
91}
92
93proc test_touch {} {
94    set root "/tmp/macports-portutil-touch"
95    file delete -force $root
96   
97    try {
98        touch -c $root
99        if {[file exists $root]} { error "touch failed" }
100   
101        touch $root
102        if {![file exists $root]} { error "touch failed" }
103   
104        touch -a -t 199912010001.01 $root
105        if {[file atime $root] != [clock scan 19991201T000101]} { error "touch failed" }
106        if {[file mtime $root] == [clock scan 19991201T000101]} { error "touch failed" }
107   
108        touch -m -t 200012010001.01 $root
109        if {[file atime $root] == [clock scan 20001201T000101]} { error "touch failed" }
110        if {[file mtime $root] != [clock scan 20001201T000101]} { error "touch failed" }
111   
112        touch -a -m -t 200112010001.01 $root
113        if {[file atime $root] != [clock scan 20011201T000101]} { error "touch failed" }
114        if {[file mtime $root] != [clock scan 20011201T000101]} { error "touch failed" }
115   
116        touch -r ~ $root
117        if {[file atime $root] != [file atime ~]} { error "touch failed" }
118        if {[file mtime $root] != [file mtime ~]} { error "touch failed" }
119    } finally {
120        file delete -force $root
121    }
122}
123
124proc test_ln {} {
125    set root "/tmp/macports-portutil-ln"
126    file delete -force $root
127   
128    file mkdir $root
129    try {
130        close [open $root/a w]
131        ln -s a $root/b
132        if {[catch {file type $root/b}] || [file type $root/b] ne "link"} {
133            set message "ln failed: "
134            if {[catch {file type $root/b}]} {
135                append message "symlink not created"
136            } elseif {[file type $root/b] ne "link"} {
137                append message "created [file type $root/b], expected link"
138            }
139            error $message
140        }
141   
142        close [open $root/c w]
143        if {![catch {ln -s c $root/b}]} { error "ln failed" }
144   
145        ln -s -f c $root/b
146        if {[catch {file type $root/b}] || [file type $root/b] ne "link"} { error "ln failed" }
147   
148        file delete $root/b
149   
150        ln $root/a $root/b
151        if {[catch {file type $root/b}] || [file type $root/b] ne "file"} { error "ln failed" }
152   
153        file delete $root/b
154        file mkdir $root/dir
155        ln -s dir $root/b
156        ln -s a $root/b
157        if {[catch {file type $root/dir/a}] || [file type $root/dir/a] ne "link"} { error "ln failed" }
158        file delete $root/dir/a
159   
160        ln -s -f -h a $root/b
161        if {[catch {file type $root/b}] || [file type $root/b] ne "link" || [file readlink $root/b] ne "a"} { error "ln failed" }
162   
163        cd $root/dir
164        ln -s ../c
165        if {[catch {file type $root/dir/c}] || [file type $root/dir/c] ne "link"} { error "ln failed" }
166   
167        ln -s foobar $root/d
168        if {[catch {file type $root/d}] || [file type $root/d] ne "link" || [file readlink $root/d] ne "foobar"} { error "ln failed" }
169       
170        ln -s -f -h z $root/dir
171        if {[catch {file type $root/dir/z}] || [file type $root/dir/z] ne "link"} { error "ln failed" }
172       
173        # test combined flags
174        ln -sf q $root/dir
175        if {[catch {file type $root/dir/q}] || [file type $root/dir/q] ne "link"} { error "ln failed" }
176    } finally {
177        file delete -force $root
178    }
179}
180
181# Create a filesystem hierarchy based on the given specification
182# The mtree spec consists of name/type pairings, where type can be
183# one of directory, file or link. If type is link, it must be a
184# two-element list containing the path as the second element
185proc mtree {root spec} {
186    foreach {entry typelist} $spec {
187        set type [lindex $typelist 0]
188        set link [lindex $typelist 1]
189        set file [file join $root $entry]
190        switch $type {
191            directory {
192                file mkdir $file
193            }
194            file {
195                # touch
196                close [open $file w]
197            }
198            link {
199                # file link doesn't let you link to files that don't exist
200                # so lets farm out to /bin/ln
201                exec /bin/ln -s $link $file
202            }
203            default {
204                return -code error "Unknown file map type: $typelist"
205            }
206        }
207    }
208}
209
210# run all tests
211foreach proc [info procs test_*] {
212    $proc
213}
214
215# namespace eval tests
216}
Note: See TracBrowser for help on using the repository browser.