Eskil

Check-in [a97748bfa1]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Run tests from source to support code coverage.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: a97748bfa197c0c1182178ef18f664131e5f8585
User & Date: peter.spjuth@gmail.com 2011-09-30 23:07:35.000
Context
2011-10-04
03:20
Fall back to tcl file dialog when in a vfs. check-in: 196758b649 user: peter.spjuth@gmail.com tags: trunk
2011-09-30
23:07
Run tests from source to support code coverage. check-in: a97748bfa1 user: peter.spjuth@gmail.com tags: trunk
2011-05-27
06:09
Cleanup of global variable usage. check-in: ef2a6449e0 user: peter.spjuth@gmail.com tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to Makefile.
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
	@./tests/all.tcl

#----------------------------------------------------------------
# Coverage
#----------------------------------------------------------------

# Source files for code coverage
COVFILES = src/rev.tcl src/eskil.tcl
IFILES   = $(COVFILES:.tcl=.tcl_i)
LOGFILES = $(COVFILES:.tcl=.tcl_log)
MFILES   = $(COVFILES:.tcl=.tcl_m)

# Instrument source file for code coverage
%.tcl_i: %.tcl
	@$(NAGELFAR) -instrument $<

# Target to prepare for code coverage run. Makes sure log file is clear.
instrument: $(IFILES)
	@rm -f $(LOGFILES)

# Run tests to create log file.
testcover $(LOGFILES): $(IFILES)







|





|
|







122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
	@./tests/all.tcl

#----------------------------------------------------------------
# Coverage
#----------------------------------------------------------------

# Source files for code coverage
COVFILES = eskil.vfs/main.tcl eskil.vfs/src/rev.tcl eskil.vfs/src/eskil.tcl eskil.vfs/src/merge.tcl
IFILES   = $(COVFILES:.tcl=.tcl_i)
LOGFILES = $(COVFILES:.tcl=.tcl_log)
MFILES   = $(COVFILES:.tcl=.tcl_m)

# Instrument source file for code coverage
%.tcl_i: %.tcl eskil_h.syntax
	@$(NAGELFAR) -instrument eskil_h.syntax $<

# Target to prepare for code coverage run. Makes sure log file is clear.
instrument: $(IFILES)
	@rm -f $(LOGFILES)

# Run tests to create log file.
testcover $(LOGFILES): $(IFILES)
Changes to tests/all.tcl.
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#tcltest::configure -match print-*

package require Tk
wm withdraw .

set ::eskil_testsuite 1

if {[file exists src/eskil.tcl_i]} {
    puts "Running with code coverage"
    source src/eskil.tcl_i
} else {
    source src/eskil.tcl
}
Init

# Helpers to temporarily stub things out
set ::stubs {}
proc stub {name argv body} {
    if {[info commands _stub_$name] eq ""} {







|

|

|







17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#tcltest::configure -match print-*

package require Tk
wm withdraw .

set ::eskil_testsuite 1

if {[file exists eskil.vfs/src/eskil.tcl_i]} {
    puts "Running with code coverage"
    source eskil.vfs/src/eskil.tcl_i
} else {
    source eskil.vfs/src/eskil.tcl
}
Init

# Helpers to temporarily stub things out
set ::stubs {}
proc stub {name argv body} {
    if {[info commands _stub_$name] eq ""} {
43
44
45
46
47
48
49



50
51
52
53
54
55
56
57
58
59
    foreach name $::stubs {
        rename $name {}
        rename _stub_$name $name
    }
    set ::stubs {}
}





puts "Running Tests"

foreach test [glob -nocomplain $testDir/*.test] {
    source $test
    clearstub
}
tcltest::cleanupTests 1

exit







>
>
>










43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
    foreach name $::stubs {
        rename $name {}
        rename _stub_$name $name
    }
    set ::stubs {}
}

proc ExecEskil {args} {
    return [exec ./eskil.kit {*}$args]
}

puts "Running Tests"

foreach test [glob -nocomplain $testDir/*.test] {
    source $test
    clearstub
}
tcltest::cleanupTests 1

exit
Changes to tests/gui.test.
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
	exec xhost -$host
    }
    exec xhost -
}
XauthSecure

proc RestartClient {args} {







    set ::clientfile ./eskil.kit
    #if {[file exists ${::clientfile}_i]} {
    #    set ::clientfile ${::clientfile}_i
    #}

    if {![catch {send -async Eskil exit}]} {
        update
        after 500
    }

    set slavepid [exec $::clientfile -server {*}$args &]

    after 1000
    while {[catch {tktest::init Eskil}]} {
        after 500
    }
    tktest::cmd wm geometry . +10+10








>
>
>
>
>
>
>
|









|







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
	exec xhost -$host
    }
    exec xhost -
}
XauthSecure

proc RestartClient {args} {
    if {[file exists eskil.vfs/main.tcl_i]} {
        puts "Starting gui instrumented"
        set src eskil.vfs/main.tcl_i
    } else {
        set src eskil.vfs/main.tcl
    }
    set cmd [list tclkit $src]
    #set ::clientfile ./eskil.kit
    #if {[file exists ${::clientfile}_i]} {
    #    set ::clientfile ${::clientfile}_i
    #}

    if {![catch {send -async Eskil exit}]} {
        update
        after 500
    }

    set slavepid [exec {*}$cmd -server {*}$args &]

    after 1000
    while {[catch {tktest::init Eskil}]} {
        after 500
    }
    tktest::cmd wm geometry . +10+10

Changes to tests/print.test.
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
    puts $ch1 "Diffline2.1"
    puts $ch2 "Diffline2.2"
    puts $ch1 $data
    puts $ch2 $data
    close $ch1
    close $ch2
} -body {
    set res [exec ./eskil.kit -context 5 -printpdf $f3 $f1 $f2]
    puts $res
    set ch [open $f3 r]
    set data [read $ch]
    close $ch
    # Check that line numbers take up 7 chars
    string match "*(    3: )*(24690: )*" $data
} -cleanup {
    tcltest::removeFile {} _test1
    tcltest::removeFile {} _test2
    tcltest::removeFile {} _test3
} -result {1}

test print-3.1 {Pdf, cmd line} -body {
    set res [exec ./eskil.kit -printHeaderSize x]
} -result {Argument -printHeaderSize must be a positive number}

test print-3.2 {Pdf, cmd line} -body {
    set res [exec ./eskil.kit -printCharsPerLine -5]
} -result {Argument -printCharsPerLine must be a positive number}

test print-3.3 {Pdf, cmd line} -body {
    set res [exec ./eskil.kit -printPaper qx]
} -match glob -result {Argument -printPaper must be a valid paper size*}

test print-3.4 {Pdf, cmd line} -body {
    set res [exec ./eskil.kit -printColorChange x]
} -result {Argument -printColorChange must be a list of RBG values from 0.0 to 1.0}

test print-3.5 {Pdf, cmd line} -body {
    set res [exec ./eskil.kit -printColorOld "0 1 2"]
} -result {Argument -printColorOld must be a list of RBG values from 0.0 to 1.0}

test print-3.6 {Pdf, cmd line} -body {
    set res [exec ./eskil.kit -printColorNew "0 -1 0.5"]
} -result {Argument -printColorNew must be a list of RBG values from 0.0 to 1.0}







|













|



|



|



|



|



|

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
    puts $ch1 "Diffline2.1"
    puts $ch2 "Diffline2.2"
    puts $ch1 $data
    puts $ch2 $data
    close $ch1
    close $ch2
} -body {
    set res [ExecEskil -context 5 -printpdf $f3 $f1 $f2]
    puts $res
    set ch [open $f3 r]
    set data [read $ch]
    close $ch
    # Check that line numbers take up 7 chars
    string match "*(    3: )*(24690: )*" $data
} -cleanup {
    tcltest::removeFile {} _test1
    tcltest::removeFile {} _test2
    tcltest::removeFile {} _test3
} -result {1}

test print-3.1 {Pdf, cmd line} -body {
    set res [ExecEskil -printHeaderSize x]
} -result {Argument -printHeaderSize must be a positive number}

test print-3.2 {Pdf, cmd line} -body {
    set res [ExecEskil -printCharsPerLine -5]
} -result {Argument -printCharsPerLine must be a positive number}

test print-3.3 {Pdf, cmd line} -body {
    set res [ExecEskil -printPaper qx]
} -match glob -result {Argument -printPaper must be a valid paper size*}

test print-3.4 {Pdf, cmd line} -body {
    set res [ExecEskil -printColorChange x]
} -result {Argument -printColorChange must be a list of RBG values from 0.0 to 1.0}

test print-3.5 {Pdf, cmd line} -body {
    set res [ExecEskil -printColorOld "0 1 2"]
} -result {Argument -printColorOld must be a list of RBG values from 0.0 to 1.0}

test print-3.6 {Pdf, cmd line} -body {
    set res [ExecEskil -printColorNew "0 -1 0.5"]
} -result {Argument -printColorNew must be a list of RBG values from 0.0 to 1.0}