Ticket #33943: test-destroot-cmd-against-gmake.patch

File test-destroot-cmd-against-gmake.patch, 2.8 KB (added by j-macports@…, 12 years ago)

Proposed fix, with unit tests

  • src/port1.0/portdestroot.tcl

     
    9292proc portdestroot::destroot_getargs {args} {
    9393    if {(([option build.type] == "default" && [option os.platform] != "freebsd") || \
    9494         ([option build.type] == "gnu")) \
    95         && [regexp "^(/\\S+/|)(g|gnu|)make(\\s+.*|)$" [option build.cmd]]} {
     95        && [regexp "^(/\\S+/|)(g|gnu|)make(\\s+.*|)$" [option destroot.cmd]]} {
    9696        # Print "Entering directory" lines for better log debugging
    9797        return "-w [option destroot.target]"
    9898    }
  • src/port1.0/tests/portdestroot.tcl

     
     1package require macports
     2mportinit
     3
     4source [file dirname [info script]]/../portdestroot.tcl
     5source [file dirname [info script]]/common.tcl
     6
     7namespace eval tests {
     8
     9proc "when destroot cmd is not gmake no -w argument is added" {} {
     10    global build.type build.cmd destroot.cmd destroot.target
     11
     12    set build.type "gnu"
     13    set build.cmd "gmake"
     14    set destroot.cmd "_destroot_cmd_"
     15    set destroot.target "_target_"
     16
     17    test_equal {[portdestroot::destroot_getargs]} "_target_"
     18}
     19
     20proc "when destroot cmd is gmake a -w argument is added" {} {
     21    global build.type build.cmd destroot.cmd destroot.target
     22
     23    set build.type "gnu"
     24    set build.cmd "_build_cmd_"
     25    set destroot.cmd "gmake"
     26    set destroot.target "_target_"
     27
     28    test_equal {[portdestroot::destroot_getargs]} "-w _target_"
     29}
     30
     31
     32# run all tests
     33foreach proc [info procs *] {
     34    puts "* ${proc}"
     35    $proc
     36}
     37
     38# namespace eval tests
     39}
  • src/port1.0/tests/common.tcl

     
     1proc test_equal {statement value} {
     2    uplevel 1 "\
     3        puts -nonewline {checking if $statement == \"$value\"... }
     4        if {\[catch {
     5                set actual $statement
     6                if {\$actual == \[subst {$value}\]} { \n\
     7                    puts yes
     8                } else { \n\
     9                    puts \"no (was \$actual)\" \n\
     10                    exit 1 \n\
     11                } \n\
     12            } msg\]} { \n\
     13                puts \"caught error: \$msg\" \n\
     14                exit 1 \n\
     15            }"
     16}
     17
     18
  • src/port1.0/Makefile

     
    3333
    3434test::
    3535        ${TCLSH} tests/portutil.tcl ${macports_tcl_dir}
     36        ${TCLSH} tests/portdestroot.tcl