diff options
author | Stephen D. Huston <shuston@apache.org> | 2009-10-15 00:38:18 +0000 |
---|---|---|
committer | Stephen D. Huston <shuston@apache.org> | 2009-10-15 00:38:18 +0000 |
commit | 4d5e7ba350d4076296e1ca3fab39dbc36a640d50 (patch) | |
tree | c9a40fdb358dee54455338fa61811ec98fea3f93 /cpp/src | |
parent | 0aca464453c5c4ed3fb0f536445a998ca8a9c7c8 (diff) | |
download | qpid-python-4d5e7ba350d4076296e1ca3fab39dbc36a640d50.tar.gz |
Improved test output capturing in automated tests; correctly get exe process exit codes
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@825358 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/tests/find_prog.ps1 | 36 | ||||
-rw-r--r-- | cpp/src/tests/quick_topictest.ps1 | 2 | ||||
-rw-r--r-- | cpp/src/tests/run_header_test.ps1 | 8 | ||||
-rw-r--r-- | cpp/src/tests/run_test.ps1 | 35 | ||||
-rw-r--r-- | cpp/src/tests/topictest.ps1 | 9 |
5 files changed, 62 insertions, 28 deletions
diff --git a/cpp/src/tests/find_prog.ps1 b/cpp/src/tests/find_prog.ps1 new file mode 100644 index 0000000000..5c482debbf --- /dev/null +++ b/cpp/src/tests/find_prog.ps1 @@ -0,0 +1,36 @@ +#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+# Locate the subdirectory where the specified program resides; the program
+# must have a directory and a file name, even if the directory is .
+param(
+ [string] $prog # program to look for somewhere below cwd
+)
+
+$dir = Split-Path $prog
+$exe = Split-Path $prog -leaf
+$sub = ""
+$subs = "Debug","Release","MinSizeRel","RelWithDebInfo"
+foreach ($try in $subs) {
+ $prog = "$dir\$try\$exe"
+ if (Test-Path $prog) {
+ $sub = $try
+ break
+ }
+}
diff --git a/cpp/src/tests/quick_topictest.ps1 b/cpp/src/tests/quick_topictest.ps1 index b1e0ed1f7d..b2efbdd684 100644 --- a/cpp/src/tests/quick_topictest.ps1 +++ b/cpp/src/tests/quick_topictest.ps1 @@ -20,7 +20,7 @@ # Quick and quiet topic test for make check. [string]$me = $myInvocation.InvocationName $srcdir = Split-Path $me -powershell "$srcdir\topictest.ps1" -subscribers 2 -messages 2 -batches 1 > topictest.log 2>&1 +& "$srcdir\topictest.ps1" -subscribers 2 -messages 2 -batches 1 > topictest.log 2>&1 if (!$?) { "$me FAILED:" cat topictest.log diff --git a/cpp/src/tests/run_header_test.ps1 b/cpp/src/tests/run_header_test.ps1 index c7bc2d788e..7d3e43a30f 100644 --- a/cpp/src/tests/run_header_test.ps1 +++ b/cpp/src/tests/run_header_test.ps1 @@ -35,13 +35,7 @@ if (Test-Path qpidd.port) { # Test runs from the tests directory but the test executables are in a # subdirectory based on the build type. Look around for it before trying # to start it. -$subs = "Debug","Release","MinSizeRel","RelWithDebInfo" -foreach ($sub in $subs) { - $prog = ".\$sub\header_test.exe" - if (Test-Path $prog) { - break - } -} +. $srcdir\find_prog.ps1 .\header_test.exe if (!(Test-Path $prog)) { "Cannot locate header_test.exe" exit 1 diff --git a/cpp/src/tests/run_test.ps1 b/cpp/src/tests/run_test.ps1 index 551368bc9b..f1afb292e7 100644 --- a/cpp/src/tests/run_test.ps1 +++ b/cpp/src/tests/run_test.ps1 @@ -17,6 +17,8 @@ # under the License. # +$srcdir = Split-Path $myInvocation.InvocationName + # Set up environment and run a test executable or script. $env:QPID_DATA_DIR = "" $env:BOOST_TEST_SHOW_PROGRESS = "yes" @@ -33,18 +35,10 @@ if (Test-Path $prog) { $env:PATH += ";.." } else { - $dir = Split-Path $prog - $exe = Split-Path $prog -leaf - $subs = "Debug","Release","MinSizeRel","RelWithDebInfo" - foreach ($sub in $subs) { - $prog = "$dir\$sub\$exe" - if (Test-Path $prog) { - $args[0] = $prog - $env:QPID_LIB_DIR = "..\$sub" - $env:PATH += ";..\$sub" - break - } - } + . $srcdir\find_prog.ps1 $prog + $args[0] = $prog + $env:QPID_LIB_DIR = "..\$sub" + $env:PATH += "$dir\$sub;..\$sub" } # If qpidd.port exists and is not empty run test with QPID_PORT set. @@ -54,18 +48,25 @@ if (Test-Path qpidd.port) { $si = new-object System.Diagnostics.ProcessStartInfo $si.WorkingDirectory = $pwd -$si.UseShellExecute = $true - +$si.UseShellExecute = $false +$si.CreateNoWindow = $true +$si.RedirectStandardOutput = $true if ($is_script) { $si.FileName = (get-command powershell.exe).Definition $si.Arguments = $args } else { $si.FileName = $args[0] - if ($args.length > 1) { - $si.Arguments = $args[1..$args.length-1] + if ($args.length -gt 1) { + $si.Arguments = $args[1..($args.length-1)] } } $p = [System.Diagnostics.Process]::Start($si) +$line = "" +while (($line = $p.StandardOutput.ReadLine()) -ne $null) { + $line +} +# ReadToEnd() works, but doesn't show any output until the program exits. +#$p.StandardOutput.ReadToEnd() $p.WaitForExit() -exit $? +exit $p.ExitCode diff --git a/cpp/src/tests/topictest.ps1 b/cpp/src/tests/topictest.ps1 index 58ae50c67c..0d22cea657 100644 --- a/cpp/src/tests/topictest.ps1 +++ b/cpp/src/tests/topictest.ps1 @@ -18,6 +18,7 @@ # # Run the C++ topic test +$srcdir = Split-Path $myInvocation.InvocationName # Parameters with default values: s (subscribers) m (messages) b (batches) # h (host) t (false; use transactions) @@ -36,21 +37,23 @@ if ($t) { $transactional = "--transactional --durable" } +# Find which subdir the exes are in +. $srcdir\find_prog.ps1 .\topic_listener.exe + function subscribe { param ([int]$num) "Start subscriber $num" $LOG = "subscriber_$num.log" - $cmdline = "$env:OUTDIR\topic_listener $transactional > $LOG 2>&1 + $cmdline = ".\$sub\topic_listener $transactional > $LOG 2>&1 if (`$LastExitCode -ne 0) { Remove-Item $LOG }" $cmdblock = $executioncontext.invokecommand.NewScriptBlock($cmdline) . $srcdir\background.ps1 $cmdblock } function publish { - Invoke-Expression "$env:OUTDIR\topic_publisher --messages $messages --batches $batches --subscribers $subscribers $host $transactional" 2>&1 + Invoke-Expression ".\$sub\topic_publisher --messages $messages --batches $batches --subscribers $subscribers $host $transactional" 2>&1 } -$srcdir = Split-Path $MyInvocation.MyCommand.Path if ($broker.length) { $broker = "-h$broker" } |