File: test394.py

package info (click to toggle)
jython 2.7.3%2Brepack1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 62,820 kB
  • sloc: python: 641,384; java: 306,981; xml: 2,066; sh: 514; ansic: 126; makefile: 77
file content (78 lines) | stat: -rw-r--r-- 2,560 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
"""
Test standalone starting,
where the manifest of a .jar refers to jython.jar


This used to give an error importing site, as follows:

error importing site
Traceback (innermost last):
  File "C:\workspace\jython\bugtests\test394jar\jython-dev.jar\Lib/site.py", line 210, in ?
TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'
Traceback (innermost last):
  File "C:/workspace/jython/bugtests/test394.py", line 71, in ?
  File "C:\workspace\jython\bugtests\support.py", line 100, in runJavaJar
  File "C:\workspace\jython\bugtests\support.py", line 65, in execCmd
TestError: cmd /C "C:/Programme/Java/jdk1.5.0_09/bin/java.exe -jar test394jar/run.jar " failed with -1

"""

import support
import sys
import os

import support_config as cfg

from java.io import File

TESTDIR = "test394jar"
JYTHON_DEV_JAR = "jython-dev.jar"
RUN_JAR = "run.jar"
TEST_PY_NAME = TESTDIR +"/test394called.py"
CLAZZ = "Runner"
MANIFEST = "MANIFEST.MF"

def checkTestDir():
  if not os.path.exists(TESTDIR):
    raise AssertionError, TESTDIR + " does not exist"
  if not os.path.exists(TEST_PY_NAME):
    raise AssertionError, TEST_PY_NAME + " does not exist"
  javaFileName = TESTDIR + "/" + CLAZZ + ".java"
  if not os.path.exists(javaFileName):
    raise AssertionError, javaFileName + " does not exist"
  manifestFileName = TESTDIR + "/" + MANIFEST
  if not os.path.exists(manifestFileName):
    raise AssertionError, manifestFileName + " does not exist"
                        
  
# create a jython standalone jar file:
# add the contents of jython-dev.jar and /Lib files to a new jython-dev.jar
def mkJythonJar():
  jarFile = File(TESTDIR, JYTHON_DEV_JAR)
  jarPacker = support.JarPacker(jarFile)
  jarPacker.addJarFile(File(cfg.jython_home + "/%s" % JYTHON_DEV_JAR))
  jarPacker.addDirectory(File(cfg.jython_home + "/Lib"))
  jarPacker.close()
  return jarFile
  
# make a java class calling jython main
def mkJavaClass():
  support.compileJava("%s/%s.java" % (TESTDIR, CLAZZ))

# create a runnable jar file with a manifest referring to jython-dev.jar
def mkRunJar():
  jarFile = File(TESTDIR, RUN_JAR)
  manifestFile = File(TESTDIR, MANIFEST)
  jarPacker = support.JarPacker(jarFile)
  jarPacker.addManifestFile(manifestFile)
  jarPacker.addFile(File(TESTDIR, CLAZZ+".class"), TESTDIR)
  jarPacker.close()
                       
                    

checkTestDir()
mkJythonJar()
mkJavaClass()
mkRunJar()
jarFileName = "%s/%s" % (TESTDIR, RUN_JAR)
support.runJavaJar(jarFileName)