jeudi 20 juillet 2017

Tcl test script execution does not end

I have five files as described below:

run_tests.tcl

package require tcltest
namespace import ::tcltest::*

if {$argc!=0} {
    foreach {flag param} $::argv {
        if {[string match -* $flag]} {
            configure $flag $param
        }\
        else {
            $flag $param
        }
    }
}
runAllTests



add.test

package require tcltest
namespace import ::tcltest::*
source add.tcl

test add1 {} -body {
    add 1 1
} -result 2

cleanupTests



add.tcl

proc add {a b} {
    return [expr $a+$b]
}



sample.test

package require tcltest
namespace import ::tcltest::*
source sample.tcl
test google_search {} -body {
    search
} -result 1

cleanupTests



sample.tcl

package require selenium::chrome

proc search {} {
    set driver [::selenium::ChromeDriver new] 
    $driver get "https://google.com"
    set query [$driver find_element_by_name "q"]
    $driver send_keys $query "selenium and Tcl"
    $driver send_keys $query $selenium::Key(RETURN)
    after 5000
    $driver close
    return 1
}



Now, if I try to execute the test file add.test by running the command tclsh run_tests.tcl -file add.test from terminal, it generates the following output:

Tests running in interp:  /usr/bin/tclsh
Tests located in:  /home/snehasish/tcl_test/tests
Tests running in:  /home/snehasish/tcl_test/tests
Temporary files stored in /home/snehasish/tcl_test/tests
Test files run in separate interpreters
Running tests that match:  *
Skipping test files that match:  l.*.test
Only running test files that match:  add.test
Tests began at Thu Jul 20 12:49:22 UTC 2017
add.test

Tests ended at Thu Jul 20 12:49:22 UTC 2017
run_tests.tcl:  Total   1   Passed  1   Skipped 0   Failed  0
Sourced 1 Test Files.

which is perfectly fine, and is what it should be.

Whereas, if I try to execute the test file sample.test in a similar way, the test does not end:

$ tclsh run_tests.tcl -file sample.test

Tests running in interp:  /usr/bin/tclsh
Tests located in:  /home/snehasish/tcl_test/tests
Tests running in:  /home/snehasish/tcl_test/tests
Temporary files stored in /home/snehasish/tcl_test/tests
Test files run in separate interpreters
Running tests that match:  *
Skipping test files that match:  l.*.test
Only running test files that match:  sample.test
Tests began at Thu Jul 20 12:27:38 UTC 2017
sample.test
Starting ChromeDriver 2.30.477691 (6ee44a7247c639c0703f291d320bdf05c1531b57) on port 42433
Only local connections are allowed.

and it stops right there and as if waits for something to happen. The browser gets closed suggesting that the web-driver indeed gets closed.

Interestingly enough, when I run sample.test directly, it gives the expected output and ends normally:

$ tclsh sample.test 

Starting ChromeDriver 2.30.477691 (6ee44a7247c639c0703f291d320bdf05c1531b57) on port 37381
Only local connections are allowed.
sample.test:    Total   1   Passed  1   Skipped 0   Failed  0

The package for Selenium Web-driver implementation I am using is available here.

Could someone please clarify why tcltest is not working as expected when using runAllTests and a web-driver script in combinaton? It would be very helpful. Thanks in advance.

PS: I am sorry that the question became too long due to the inclusion of the contents of a number of files, but I thought this is the way in which I would be more clear in explaining my question.

Aucun commentaire:

Enregistrer un commentaire