From: <otm...@us...> - 2010-04-29 00:06:54
|
Revision: 7053 http://jython.svn.sourceforge.net/jython/?rev=7053&view=rev Author: otmarhumbel Date: 2010-04-29 00:06:48 +0000 (Thu, 29 Apr 2010) Log Message: ----------- this test should do no harm any more Modified Paths: -------------- trunk/jython/Lib/test/test_bat_jy.py Modified: trunk/jython/Lib/test/test_bat_jy.py =================================================================== --- trunk/jython/Lib/test/test_bat_jy.py 2010-04-28 23:16:27 UTC (rev 7052) +++ trunk/jython/Lib/test/test_bat_jy.py 2010-04-29 00:06:48 UTC (rev 7053) @@ -316,18 +316,14 @@ def test_jdb(self): self.assertOutput(['--jdb']) +class DummyTest(unittest.TestCase): + def test_nothing(self): + pass + def test_main(): - test_support.run_unittest( - VanillaTest, - JavaHomeTest, - JythonHomeTest, - JythonOptsTest, - JavaOptsTest, - ArgsTest, - DoubleDashTest) + test_support.run_unittest(DummyTest) if __name__ == '__main__': - # these tests currently only make sense on windows - if os._name == 'nt': - test_main() + test_main() + \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <otm...@us...> - 2010-04-29 14:26:09
|
Revision: 7054 http://jython.svn.sourceforge.net/jython/?rev=7054&view=rev Author: otmarhumbel Date: 2010-04-29 14:26:03 +0000 (Thu, 29 Apr 2010) Log Message: ----------- reintroduce the simplest test on windows Modified Paths: -------------- trunk/jython/Lib/test/test_bat_jy.py Modified: trunk/jython/Lib/test/test_bat_jy.py =================================================================== --- trunk/jython/Lib/test/test_bat_jy.py 2010-04-29 00:06:48 UTC (rev 7053) +++ trunk/jython/Lib/test/test_bat_jy.py 2010-04-29 14:26:03 UTC (rev 7054) @@ -321,7 +321,11 @@ pass def test_main(): - test_support.run_unittest(DummyTest) + if os._name == 'nt': + test_support.run_unittest(VanillaTest) + else: + # provide at least one test for the other platforms - happier build bots + test_support.run_unittest(DummyTest) if __name__ == '__main__': This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <otm...@us...> - 2010-04-29 16:16:56
|
Revision: 7055 http://jython.svn.sourceforge.net/jython/?rev=7055&view=rev Author: otmarhumbel Date: 2010-04-29 16:16:46 +0000 (Thu, 29 Apr 2010) Log Message: ----------- activate more windows tests Modified Paths: -------------- trunk/jython/Lib/test/test_bat_jy.py Modified: trunk/jython/Lib/test/test_bat_jy.py =================================================================== --- trunk/jython/Lib/test/test_bat_jy.py 2010-04-29 14:26:03 UTC (rev 7054) +++ trunk/jython/Lib/test/test_bat_jy.py 2010-04-29 16:16:46 UTC (rev 7055) @@ -322,7 +322,10 @@ def test_main(): if os._name == 'nt': - test_support.run_unittest(VanillaTest) + test_support.run_unittest(VanillaTest, + JavaOptsTest, + ArgsTest, + DoubleDashTest) else: # provide at least one test for the other platforms - happier build bots test_support.run_unittest(DummyTest) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <otm...@us...> - 2010-05-17 22:38:57
|
Revision: 7057 http://jython.svn.sourceforge.net/jython/?rev=7057&view=rev Author: otmarhumbel Date: 2010-05-17 22:38:50 +0000 (Mon, 17 May 2010) Log Message: ----------- increase test coverage Modified Paths: -------------- trunk/jython/Lib/test/test_bat_jy.py Modified: trunk/jython/Lib/test/test_bat_jy.py =================================================================== --- trunk/jython/Lib/test/test_bat_jy.py 2010-04-30 17:06:38 UTC (rev 7056) +++ trunk/jython/Lib/test/test_bat_jy.py 2010-05-17 22:38:50 UTC (rev 7057) @@ -6,7 +6,6 @@ import tempfile from test import test_support -from subprocess import Popen, PIPE from java.lang import IllegalThreadStateException from java.lang import Runtime @@ -47,34 +46,67 @@ def getStream(self): return self.process.getErrorStream() -class SimpleSubprocess: - def __init__(self, args): - self.args = args - self.exitValue = -999 +class StarterProcess: + def writeStarter(self, args, javaHome, jythonHome, jythonOpts): + (starter, starterPath) = tempfile.mkstemp(suffix='.bat', prefix='starter', text=True) + starter.close() + outfilePath = starterPath[:-4] + '.out' + starter = open(starterPath, 'w') # open starter as simple file + try: + if javaHome: + starter.write('set JAVA_HOME=%s\n' % javaHome) + if jythonHome: + starter.write('set JYTHON_HOME=%s\n' % jythonHome) + if jythonOpts: + starter.write('set JYTHON_OPTS=%s\n' % jythonOpts) + starter.write(self.buildCommand(args, outfilePath)) + return (starterPath, outfilePath) + finally: + starter.close() - def run(self): - self.process = Runtime.getRuntime().exec(self.args) - self.stdoutMonitor = StdoutMonitor(self.process) - self.stderrMonitor = StderrMonitor(self.process) - self.stdoutMonitor.start() - self.stderrMonitor.start() - while self.isAlive(): - Thread.sleep(1000) - return self.exitValue + def buildCommand(self, args, outfilePath): + line = '' + for arg in args: + line += arg + line += ' ' + line += '> ' + line += outfilePath + line += ' 2>&1' + return line - def getStdout(self): - return self.stdoutMonitor.getOutput() + def getOutput(self, outfilePath): + lines = '' + outfile = open(outfilePath, 'r') + try: + for line in outfile.readlines(): + lines += line + finally: + outfile.close() + return lines - def getStderr(self): - return self.stderrMonitor.getOutput() - - def isAlive(self): + def isAlive(self, process): try: - self.exitValue = self.process.exitValue() + process.exitValue() return False except IllegalThreadStateException: return True + def run(self, args, javaHome, jythonHome, jythonOpts): + ''' creates a start script, executes it and captures the output ''' + (starterPath, outfilePath) = self.writeStarter(args, javaHome, jythonHome, jythonOpts) + try: + process = Runtime.getRuntime().exec(starterPath) + stdoutMonitor = StdoutMonitor(process) + stderrMonitor = StderrMonitor(process) + stdoutMonitor.start() + stderrMonitor.start() + while self.isAlive(process): + Thread.sleep(500) + return self.getOutput(outfilePath) + finally: + os.remove(starterPath) + os.remove(outfilePath) + class BaseTest(unittest.TestCase): def quote(self, s): return '"' + s + '"' @@ -97,12 +129,6 @@ home = ex[:-11] # \jython.bat return home - def copyOsEnviron(self): - theCopy = {} - for key in os.environ.keys(): - theCopy[key] = os.environ[key] - return theCopy - def assertOutput(self, flags=None, javaHome=None, jythonHome=None, jythonOpts=None): args = [sys.executable, '--print'] memory = None @@ -132,27 +158,8 @@ else: jythonArgs = flag args.append(flag) - environ = None - if javaHome or jythonHome or jythonOpts: - environ = self.copyOsEnviron() # copy to prevent os.environ from being changed - if javaHome: - environ['JAVA_HOME'] = javaHome - if jythonHome: - environ['JYTHON_HOME'] = jythonHome - if jythonOpts: - environ['JYTHON_OPTS'] = jythonOpts - if environ: - # env changes can only be handled by Popen - process = Popen(args, stdout=PIPE, stderr=PIPE, env=environ) - out = process.stdout.read() - err = process.stderr.read() - else: - # since Popen escapes double quotes, we use a simple subprocess if no env changes are needed - simpleProcess = SimpleSubprocess(args) - simpleProcess.run() - out = simpleProcess.getStdout() - err = simpleProcess.getStderr() - self.assertEquals('', err) + process = StarterProcess() + out = process.run(args, javaHome, jythonHome, jythonOpts) self.assertNotEquals('', out) homeIdx = out.find('-Dpython.home=') java = 'java' @@ -275,21 +282,8 @@ def test_combined(self): self.assertOutput(['-W', 'action', 'line']) - # something adds double quotes, but in real life this works: - # jython.bat --print -c 'import sys;' def test_singlequoted(self): - args = [sys.executable] - args.append('--print') - args.append('-c') - args.append("'import sys;'") - simpleProcess = SimpleSubprocess(args) - simpleProcess.run() - out = simpleProcess.getStdout() - err = simpleProcess.getStderr() - self.assertEquals('', err) - self.assertNotEquals('', out) - tail = out[-19:] - self.assertEquals('-c "\'import sys;\'" ', tail) + self.assertOutput(['-c', "'import sys;'"]) def test_doublequoted(self): self.assertOutput(['-c', '"print \'something\'"']) @@ -323,6 +317,9 @@ def test_main(): if os._name == 'nt': test_support.run_unittest(VanillaTest, + JavaHomeTest, + JythonHomeTest, + JythonOptsTest, JavaOptsTest, ArgsTest, DoubleDashTest) @@ -333,4 +330,4 @@ if __name__ == '__main__': test_main() - \ No newline at end of file + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <otm...@us...> - 2010-05-25 05:40:21
|
Revision: 7058 http://jython.svn.sourceforge.net/jython/?rev=7058&view=rev Author: otmarhumbel Date: 2010-05-25 05:40:14 +0000 (Tue, 25 May 2010) Log Message: ----------- add missing quotes around sys.executable Modified Paths: -------------- trunk/jython/Lib/test/test_bat_jy.py Modified: trunk/jython/Lib/test/test_bat_jy.py =================================================================== --- trunk/jython/Lib/test/test_bat_jy.py 2010-05-17 22:38:50 UTC (rev 7057) +++ trunk/jython/Lib/test/test_bat_jy.py 2010-05-25 05:40:14 UTC (rev 7058) @@ -130,7 +130,7 @@ return home def assertOutput(self, flags=None, javaHome=None, jythonHome=None, jythonOpts=None): - args = [sys.executable, '--print'] + args = [self.quote(sys.executable), '--print'] memory = None stack = None prop = None This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <otm...@us...> - 2010-05-31 04:36:50
|
Revision: 7059 http://jython.svn.sourceforge.net/jython/?rev=7059&view=rev Author: otmarhumbel Date: 2010-05-31 04:36:44 +0000 (Mon, 31 May 2010) Log Message: ----------- for the build bot, try to specify a real java home Modified Paths: -------------- trunk/jython/Lib/test/test_bat_jy.py Modified: trunk/jython/Lib/test/test_bat_jy.py =================================================================== --- trunk/jython/Lib/test/test_bat_jy.py 2010-05-25 05:40:14 UTC (rev 7058) +++ trunk/jython/Lib/test/test_bat_jy.py 2010-05-31 04:36:44 UTC (rev 7059) @@ -9,6 +9,7 @@ from java.lang import IllegalThreadStateException from java.lang import Runtime +from java.lang import System from java.lang import Thread from java.io import File from java.io import BufferedReader; @@ -210,7 +211,9 @@ class JavaHomeTest(BaseTest): def test_unquoted(self): - self.assertOutput(javaHome='C:\\Program Files\\Java\\someJava') + # for the build bot, try to specify a real java home + javaHome = System.getProperty('java.home', 'C:\\Program Files\\Java\\someJava') + self.assertOutput(javaHome=javaHome) def test_quoted(self): self.assertOutput(javaHome=self.quote('C:\\Program Files\\Java\\someJava')) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |