Moved (long rotting) AS test code into aslib/src/test; nixed other cruft.

The AS tests are still not compiled and run, but now at least they have a nice
place to live, in case someone ever wants to resurrect them.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@6784 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2012-02-14 19:11:54 +00:00
parent 1c311431ad
commit c3e08f47d4
12 changed files with 0 additions and 621 deletions
-37
View File
@@ -1,37 +0,0 @@
#!/bin/bash
tmp=/tmp/check_genservices_temp
echo "" > $tmp
pushd .. > /dev/null
ant genservice
err=$?
popd > /dev/null
[[ $err -eq 0 ]] || exit $err
count()
{
class=$1
file=$2
perl -e '
$count = 0;
while (<>)
{
++$count if /\b'$class'\b/;
}
print $count
' $file
}
find .. \( -name \*.java -o -name \*.as \) -newer $tmp | while read file; do
egrep ^import $file | sed -e 's/;//' | while read import; do
class=${import##*.}
# echo "Checking $class in $file"
if [ $(count $class $file) -lt 2 ]; then
echo "ERROR: ${import} not used in file $file"
fi
done
done
rm $tmp
-3
View File
@@ -1,3 +0,0 @@
#!/bin/sh
`dirname $0`/runjava com.threerings.miso.viewer.ViewerApp $*
-173
View File
@@ -1,173 +0,0 @@
#!/usr/bin/python
import re, fileinput, datetime
class MatchCount:
def __init__ (self, name, regex):
self.regex = re.compile(regex)
self.ids = {}
self.name = name
def process (self, line, lineno):
m = self.regex.search(line)
if m:
self.ids[m.group("id")] = (m, lineno)
def len (self):
return len(self.ids)
logTimePat = '''\d{4}/\d{2}/\d{2} \d{2}:\d{2}:\d{2}:\d{3}'''
def report (action):
return "(?P<time>%s) \w+ com.threerings.narya.bureau: %s \[oid=(?P<id>\d+)" % (logTimePat, action)
def parseTime (time):
yr = time[0:4]
mo = time[5:7]
da = time[8:10]
hr = time[11:13]
mi = time[14:16]
se = time[17:19]
ml = time[20:23]
return datetime.datetime(int(yr), int(mo), int(da), int(hr), int(mi), int(se), int(ml) * 1000)
create = MatchCount("Immediate Creation", report("Bureau ready, sending createAgent"))
pending = MatchCount("Pending", report("Bureau not ready, pending agent"))
delayCreate = MatchCount("Delayed Creation", report("Creating agent"))
confirm = MatchCount("Confirmed created", report("Agent creation confirmed"))
fail = MatchCount("Failed creation", report("Agent creation failed"))
destroy = MatchCount("Destroy", report("Destroying agent"))
dconfirm = MatchCount("Confirmed destruction", report("Agent destruction confirmed"))
transitions = [create, delayCreate, confirm, fail, pending, destroy, dconfirm]
print "Reading log"
def readLog():
time = re.compile(logTimePat)
lastTime = None
for line in fileinput.input():
for matcher in transitions:
matcher.process(line, fileinput.lineno())
m = time.search(line)
if m != None: lastTime = m
return lastTime
lastTimeInLog = readLog()
if lastTimeInLog != None:
lastTimeInLog = parseTime(lastTimeInLog.group())
summary = False
if summary:
createCount = create.len() + delayCreate.len()
orphanCount = createCount - confirm.len() - fail.len()
print "%d created, %d started, %d failed, %d orphaned, %.1f%%" % (
createCount, confirm.len(), fail.len(), orphanCount,
(float(orphanCount) * 100 / createCount))
class Path:
def __init__(self, name, *transitions):
self.transitions = transitions
self.name = name
self.id = None
def describe (self, now):
'''Describe a path, including a description of the time since the last change'''
names = ", ".join(map(lambda t: t.name, self.transitions))
if self.id != None and len(self.transitions) > 0:
time = self.transitions[-1].ids[self.id][0].group('time')
time = parseTime(time)
names = "%s (%s ago)" % (names, describeTimeDelta(now - time))
return "%s: %s" % (self.name, names)
@staticmethod
def calculate (id):
'''Determine the sequence of transitions taken by an agent'''
path = []
for trans in transitions:
if not trans.ids.has_key(id): continue
path.append(trans)
path.sort(lambda a, b: a.ids[id][1] - b.ids[id][1])
path = Path("Agent " + id, *path)
path.id = id
return path
class PathSequence:
def __init__(self, *paths):
self.paths = paths
def match (self, path):
path = path.transitions
for i in range(0, len(self.paths)):
myPath = self.paths[i].transitions
if path == myPath:
return ("exact", self.paths[i])
if path == myPath[0:len(path)]:
return ("partial", self.paths[i])
return None
validPaths = PathSequence(
Path("Aborted", pending, destroy),
Path("Pending-normal", pending, delayCreate, confirm, destroy, dconfirm),
Path("Pending-stillborn", pending, delayCreate, destroy, confirm, dconfirm),
Path("Normal", create, confirm, destroy, dconfirm),
Path("Stillborn", create, destroy, confirm, dconfirm),
)
def describeTimeDelta (delta):
'''Quick english description of a time interval'''
seconds = delta.seconds
if delta.days > 0:
desc = "%d days"
elif seconds > 3600:
desc = "%d hours" % int(seconds/3600)
elif seconds > 60:
desc = "%s minutes" % int(seconds/60)
else:
desc = "%s seconds" % seconds
return desc
def getAllIds ():
all = {}
for trans in transitions:
for id in trans.ids.keys():
all[id] = True
all = all.keys()
all.sort(lambda a, b: int(a) - int(b))
return all
def getBureau (id, path):
# Can't get this since t is on a different log line and we only match single lines
return "??"
def checkAll (ids, now, verbose=False):
completedPathCounts = {}
for id in ids:
if verbose: print "Checking %s" % id
path = Path.calculate(id)
if verbose: print path.describe(now)
match = validPaths.match(path)
if verbose: print match
if match == None:
print "Invalid path: %s" % path.describe(now)
elif match[0] == "partial":
print "Incomplete path: %s" % path.describe(now)
elif match[0] == "exact":
completedPathCounts[match[1]] = completedPathCounts.get(match[1], 0) + 1
for path in validPaths.paths:
count = completedPathCounts.get(path, 0)
print "Path %s completed %d times" % (path.name, count)
print "Checking"
checkAll(getAllIds(), lastTimeInLog)
-87
View File
@@ -1,87 +0,0 @@
#!/usr/bin/perl -w
use Getopt::Std;
my $usage = "Usage: $0 [-p pid_file] args\n";
# locations of stuff
chomp($location = `dirname $0`);
# get the server root by popping the /bin off of our parent directory
@parts = split(/\//, $location);
pop(@parts);
my $root = join("/", @parts);
# but we're in the test directory, so we want up one
$realroot = $root;
$root = "$root/..";
# determine our machine architecture
my $ostype = `uname -s`;
my $machtype = `uname -m`;
chomp($ostype);
chomp($machtype);
my $arch = "$machtype-$ostype";
# add our native libraries to the runtime library path
my $libs = "$root/lib/$arch";
my $libpath = $ENV{"LD_LIBRARY_PATH"};
if (defined $libpath) {
$ENV{"LD_LIBRARY_PATH"} = "$libs:$libpath";
} else {
$ENV{"LD_LIBRARY_PATH"} = $libs;
}
# put everything in our class path
my $classpath = "-classpath $root/tests/dist/classes:$root/dist/classes";
# add zip and jar files from our lib/ directory and the global Java
# libraries directory
my @dirs = ( "$root/dist/lib", $ENV{"JAVA_LIBS"} );
foreach $dir (@dirs) {
next unless (defined $dir);
if (opendir(DIR, $dir)) {
foreach $lib (grep { /.(zip|jar)/ && -f "$dir/$_" } readdir(DIR)) {
# skip narya-*.jar because we have the narya build directory
# in our classpath
$classpath .= ":$dir/$lib" unless $lib =~ /narya/;
}
closedir DIR;
}
}
# finally add the standard classes
$classpath = "$classpath";
# specify our server root (this is for server code)
my $rootarg = "-Dresource_dir=$realroot/rsrc -Dtest_dir=$realroot";
my $pid_file = undef;
my $i = 0;
# strip out the -p args (we'd use getopt() but the damned thing provides
# no way of escaping arguments so that we can pass args to runjava that
# get passed down to the JVM)
for ($i = 0; $i < @ARGV; $i++) {
my $arg = $ARGV[$i];
# stop when we see -- (and strip it out because Java don't dig --)
if ($arg eq "--") {
splice(@ARGV, $i, 1);
last;
}
if ($arg eq "-p") {
$pid_file = $ARGV[$i+1];
splice(@ARGV, $i, 2);
$i -= 1; # decrement i so that things stay in sync
}
}
# log the pid file if requested to do so
print `echo $$ > $pid_file` if (defined $pid_file);
my $cmd = "java -mx256M $classpath $rootarg " . join(" ", @ARGV);
# print "$cmd\n";
exec($cmd);
-4
View File
@@ -1,4 +0,0 @@
#!/bin/sh
bindir=`dirname $0`
$bindir/runjava com.threerings.presents.client.TestClient $*
-4
View File
@@ -1,4 +0,0 @@
#!/bin/sh
bindir=`dirname $0`
$bindir/runjava $* com.threerings.presents.server.TestServer
-313
View File
@@ -1,313 +0,0 @@
<!-- build configuration -->
<project name="narya tests" default="compile" basedir=".">
<!-- import overriding properties -->
<property file="../build.properties"/>
<!-- things you may want to change -->
<property name="junit.fork" value="true"/>
<!-- things you probably don't want to change -->
<property name="test.dir" value="."/>
<property name="src.dir" value="src/java"/>
<property name="deploy.dir" value="dist"/>
<property name="lib.name" value="naryatests"/>
<property name="cbundle.dir" value="rsrc/bundles/components"/>
<property name="tbundle.dir" value="rsrc/bundles/tiles"/>
<!-- this may be changed if you don't have msoy built -->
<property name="avmthane" value="/export/msoy/dist/lib/avmthane"/>
<!-- declare our classpath -->
<property name="classes.dir" value="${deploy.dir}/classes"/>
<property name="narya.classes.dir" value="../${deploy.dir}/classes"/>
<path id="classpath">
<pathelement location="${classes.dir}"/>
<pathelement location="${narya.classes.dir}"/>
<fileset dir="../${deploy.dir}/lib" includes="**/*.jar"/>
</path>
<!-- generates additional methods for distributed object classes -->
<target name="gendobj" depends="prepare">
<taskdef name="dobj"
classname="com.threerings.presents.tools.GenDObjectTask"
classpathref="classpath"/>
<!-- make sure the dobject class files are all compiled -->
<javac srcdir="src/java" destdir="${classes.dir}" includeAntRuntime="false"
debug="on" deprecation="on" source="1.5" target="1.5">
<classpath refid="classpath"/>
<include name="**/*Object.java"/>
</javac>
<!-- now generate the associated files -->
<dobj classpathref="classpath">
<fileset dir="src/java" includes="**/*Object.java"/>
</dobj>
</target>
<!-- generates marshaller and dispatcher classes for all invocation -->
<!-- service declarations -->
<target name="genservice">
<taskdef name="service" classpathref="classpath"
classname="com.threerings.presents.tools.GenServiceTask"/>
<!-- make sure the service class files are all compiled -->
<javac srcdir="src/java" destdir="${classes.dir}" debug="on"
includeAntRuntime="false" deprecation="on" source="1.5" target="1.5">
<classpath refid="classpath"/>
<include name="**/*Service.java"/>
</javac>
<!-- now generate the associated files -->
<service header="../lib/SOURCE_HEADER" classpathref="classpath">
<fileset dir="src/java" includes="**/*Service.java"/>
</service>
</target>
<!-- generates sender and decoder classes for all invocation -->
<!-- receiver declarations -->
<target name="genreceiver">
<taskdef name="receiver" classpathref="classpath"
classname="com.threerings.presents.tools.GenReceiverTask"/>
<!-- make sure the receiver class files are all compiled -->
<javac srcdir="src/java" destdir="${classes.dir}" includeAntRuntime="false"
debug="on" deprecation="on" source="1.5" target="1.5">
<classpath refid="classpath"/>
<include name="**/*Receiver.java"/>
<exclude name="**/InvocationReceiver.java"/>
</javac>
<!-- now generate the associated files -->
<receiver header="../lib/SOURCE_HEADER" classpathref="classpath">
<fileset dir="src/java" includes="**/*Receiver.java"/>
</receiver>
</target>
<!-- generates sender and decoder classes for all invocation -->
<!-- receiver declarations -->
<target name="genascript">
<taskdef name="ascript" classpathref="classpath"
classname="com.threerings.presents.tools.GenActionScriptStreamableTask"/>
<!-- make sure the receiver class files are all compiled -->
<javac srcdir="src/java" destdir="${classes.dir}"
debug="on" deprecation="on" source="1.5" target="1.5">
<classpath refid="classpath"/>
<include name="**/ASStreamableSubset.java"/>
</javac>
<!-- now generate the associated files -->
<ascript header="../lib/SOURCE_HEADER" classpathref="classpath" asroot="src/as">
<fileset dir="src/java" includes="**/ASStreamableSubset.java"/>
</ascript>
</target>
<!-- prepares the application directories -->
<target name="prepare">
<mkdir dir="${deploy.dir}"/>
<mkdir dir="${classes.dir}"/>
<copy todir="${classes.dir}">
<fileset dir="${src.dir}" includes="**/*.properties"/>
</copy>
<copy todir="${classes.dir}/rsrc">
<fileset dir="rsrc" includes="**/*"/>
</copy>
</target>
<!-- cleans out the installed application -->
<target name="clean">
<delete dir="${deploy.dir}"/>
</target>
<!-- build the java class files -->
<target name="compile" depends="prepare">
<javac srcdir="${src.dir}" destdir="${classes.dir}" includeAntRuntime="false"
debug="on" optimize="off" deprecation="on">
<classpath refid="classpath"/>
<compilerarg value="-Xlint:unchecked"/>
</javac>
</target>
<!-- checks whether our Flash library needs building -->
<target name="checkaslib">
<condition property="no_build_aslib"><or>
<not><available file="${flexsdk.dir}/lib/compc.jar"/></not>
<and>
<uptodate targetfile="${deploy.dir}/${lib.name}.swc">
<srcfiles dir="src/as" includes="**/*.as"/>
<srcfiles dir="../dist" includes="*.swc"/>
</uptodate>
<uptodate targetfile="${deploy.dir}/${lib.name}.abc">
<srcfiles dir="src/as" includes="**/*.as"/>
<srcfiles dir="../dist" includes="*.swc"/>
</uptodate>
</and>
</or></condition>
<available property="extdep.suffix" value="-0.0-SNAPSHOT"
filepath="../dist/lib" file="thane-0.0-SNAPSHOT.swc"/>
</target>
<!-- builds our Flash library -->
<target name="aslib" unless="no_build_aslib" depends="checkaslib">
<!-- Generate aslib-config.xml for Flash Player and general compilation -->
<copy file="etc/thane-config.xml.in" tofile="${deploy.dir}/thane-config.xml">
<filterset>
<filter token="flex_sdk_dir" value="${flexsdk.dir}"/>
<filter token="lib_name" value="${lib.name}"/>
</filterset>
</copy>
<!-- Build Narya tests -->
<java jar="${flexsdk.dir}/lib/compc.jar" fork="true" failonerror="true">
<arg value="-load-config"/>
<arg value="${deploy.dir}/thane-config.xml"/>
<arg value="-compiler.optimize"/>
<arg value="-compiler.source-path=src/as/"/>
<arg value="-compiler.external-library-path"/>
<arg value="../dist/lib/thane${extdep.suffix}.swc"/>
<arg value="-compiler.library-path"/>
<arg value="../dist/thane-env.swc"/>
<arg value="../dist/naryalib.swc"/>
<arg value="-output"/>
<arg value="${deploy.dir}/${lib.name}.swc"/>
<arg value="-compiler.source-path"/>
<arg value="src/as/"/>
<arg value="-include-sources=src/as/com/threerings/bureau/client/TestClient.as"/>
</java>
<delete file="${deploy.dir}/aslib-config.xml"/>
<echo message="Turning .swc into .abc..."/>
<java outputproperty="dump" classpathref="classpath"
classname="flash.swf.tools.SwfxPrinter" fork="true" failonerror="true">
<arg value="-dump"/>
<arg value="${deploy.dir}/${lib.name}.abc"/>
<arg value="${deploy.dir}/${lib.name}.swc"/>
</java>
</target>
<target name="astest" depends="prepare">
<!-- Generate astest-config.xml for Flash Player and general compilation -->
<copy file="etc/astest-config.xml.in" tofile="${deploy.dir}/astest-config.xml">
<filterset>
<filter token="flex_sdk_dir" value="${flexsdk.dir}"/>
<filter token="lib_name" value="${lib.name}"/>
</filterset>
</copy>
<java jar="${flexsdk.dir}/lib/mxmlc.jar" fork="true" failonerror="true">
<arg value="-load-config"/>
<arg value="${deploy.dir}/astest-config.xml"/>
<arg value="-source-path+=../src/as/"/>
<arg value="-source-path+=src/as"/>
<arg value="-output=dist/naryatest.swf"/>
<arg value="src/as/com/threerings/NaryaRunner.as"/>
</java>
</target>
<!-- run the tests -->
<property name="test" value=""/>
<target name="tests" depends="compile" description="Run the tests.">
<junit printsummary="no" haltonfailure="yes" fork="${junit.fork}">
<classpath refid="classpath"/>
<sysproperty key="test_dir" value="${test.dir}"/>
<sysproperty key="resource_dir" value="${test.dir}/rsrc"/>
<formatter type="brief" usefile="false"/>
<batchtest>
<fileset dir="${src.dir}">
<include name="**/*${test}Test.java"/>
</fileset>
</batchtest>
</junit>
</target>
<!-- checks whether the bureau client needs to be compiled -->
<target name="bureau-check-thane-client">
<condition property="no_build_thane_client">
<uptodate targetfile="${deploy.dir}/BureauTestClient.abc">
<srcfiles dir="dist" includes="*.swc"/>
<srcfiles dir="src/thane" includes="**/*.as"/>
</uptodate>
</condition>
</target>
<!-- builds the bureau thane test client -->
<target name="bureau-compile-thane-client"
unless="no_build_thane_client" depends="aslib,bureau-check-thane-client"
description="Compiles the thane client for testing the bureau library">
<dirname property="abs.flexsdk.dir" file="${flexsdk.dir}/somefile.txt"/>
<copy file="etc/thane-config.xml.in" tofile="${deploy.dir}/thane-config.xml">
<filterset>
<filter token="flex_sdk_dir" value="${abs.flexsdk.dir}"/>
</filterset>
</copy>
<!-- link the executable -->
<java jar="${flexsdk.dir}/lib/mxmlc.jar" fork="true" failonerror="true">
<arg value="-load-config"/>
<arg value="${deploy.dir}/thane-config.xml"/>
<arg value="-compiler.external-library-path"/>
<arg value="../dist/lib/thane${extdep.suffix}.swc"/>
<arg value="dist/${lib.name}.swc"/>
<arg value="-compiler.source-path=src/thane"/>
<arg value="-output"/>
<arg value="${deploy.dir}/BureauTestClient.swf"/>
<arg value="src/thane/BureauTestClient.as"/>
</java>
<delete file="${deploy.dir}/thane-config.xml"/>
<echo message="Turning .swf into .abc..."/>
<java outputproperty="dump" classpathref="classpath"
classname="flash.swf.tools.SwfxPrinter" fork="true" failonerror="true">
<arg value="-dump"/>
<arg value="${deploy.dir}/BureauTestClient.abc"/>
<arg value="${deploy.dir}/BureauTestClient.swf"/>
</java>
</target>
<target name="bureau-runserver" depends="compile"
description="Run the bureau test server.">
<java fork="true" classname="com.threerings.bureau.server.TestServer">
<classpath refid="classpath"/>
</java>
</target>
<target name="bureau-testregistry" depends="compile"
description="Run the bureau test server and tests the registry.">
<java fork="true" classname="com.threerings.bureau.server.RegistryTester">
<classpath refid="classpath"/>
<sysproperty key="maxAgents" value="10"/>
<sysproperty key="numBureaus" value="2"/>
<sysproperty key="killBureauChance" value="2"/>
<sysproperty key="maxOps" value="5"/>
<sysproperty key="createChance" value="70"/>
<sysproperty key="minDelay" value="1000"/>
<sysproperty key="maxDelay" value="3000"/>
<sysproperty key="seed" value="0"/>
<sysproperty key="clientTarget" value="bureau-runclient"/>
</java>
</target>
<!-- NOTE: this target is launched by the bureau-runserver target, modelling the way bureaus -->
<!-- work. As such it is not currently useful on its own -->
<target name="bureau-runclient" depends="compile"
description="Run the bureau test client.">
<java fork="true" classname="com.threerings.bureau.client.TestClient">
<classpath refid="classpath"/>
<sysproperty key="serverName" value="${serverName}"/>
<sysproperty key="serverPort" value="${serverPort}"/>
<sysproperty key="token" value="${token}"/>
<sysproperty key="bureauId" value="${bureauId}"/>
</java>
</target>
<!-- runs the thane test client -->
<target name="bureau-run-thane-client" depends="bureau-compile-thane-client"
description="Runs the thane client for testing the bureau library">
<exec executable="${avmthane}">
<!--arg value="-Dverbose"/-->
<arg value="dist/naryatests.abc"/>
<arg value="dist/BureauTestClient.abc"/>
<arg value="--"/>
<arg value="${token}"/>
<arg value="${bureauId}"/>
<arg value="${serverName}"/>
<arg value="${serverPort}"/>
</exec>
</target>
</project>