Skip to content

Commit

Permalink
Merge 42ef3dc into 0ee5495
Browse files Browse the repository at this point in the history
  • Loading branch information
smarr committed May 27, 2018
2 parents 0ee5495 + 42ef3dc commit b45069b
Show file tree
Hide file tree
Showing 29 changed files with 1,093 additions and 78 deletions.
22 changes: 17 additions & 5 deletions build.xml
Expand Up @@ -9,6 +9,7 @@
<property name="bd.dir" location="${lib.dir}/black-diamonds/" />
<property name="unit.dir" value="tests/java" />
<property name="kompos.dir" value="tools/kompos" />
<property name="corelib.dir" value="core-lib" />
<property name="graal.dir" location="${lib.dir}/truffle/compiler" />
<property name="truffle.dir" location="${lib.dir}/truffle/truffle" />
<property name="sdk.dir" location="${lib.dir}/truffle/sdk" />
Expand Down Expand Up @@ -145,6 +146,9 @@
<fileset dir="${unit.dir}">
<include name="**/*.java"/>
</fileset>
<fileset dir="${corelib.dir}">
<include name="**/*.java"/>
</fileset>
</pathconvert>
<exec executable="${env.ECLIPSE_EXE}" dir="${basedir}">
<arg value="-nosplash"/>
Expand Down Expand Up @@ -184,7 +188,9 @@
<target name="checkstyle" depends="checkstyle-jar" description="Check Code with Checkstyle">
<taskdef resource="com/puppycrawl/tools/checkstyle/ant/checkstyle-ant-task.properties" classpath="${lib.dir}/checkstyle-${checkstyle.version}-all.jar" />
<checkstyle config=".checkstyle_checks.xml">
<fileset dir="src" includes="**/*.java"/>
<fileset dir="${src.dir}" includes="**/*.java"/>
<fileset dir="${unit.dir}" includes="**/*.java"/>
<fileset dir="${corelib.dir}" includes="**/*.java"/>
<formatter type="plain"/>
</checkstyle>
</target>
Expand Down Expand Up @@ -235,7 +241,13 @@
</javac>
</target>

<target name="compile" depends="libs,compile-som" description="Compile SOMns and dependencies">
<target name="compile" depends="libs,compile-som,compile-test-extension" description="Compile SOMns and dependencies">
</target>

<target name="compile-test-extension">
<ant dir="${corelib.dir}/TestSuite/extension" useNativeBasedir="true" target="jar" inheritAll="false">
<property name="force.java8" value="${is.atLeastJava9}" />
</ant>
</target>

<target name="kompos" description="Build Kompos">
Expand Down Expand Up @@ -274,7 +286,7 @@
<classpath refid="project.classpath" />
<jvmarg value="-ea" />
<jvmarg value="-esa" />
<arg line="core-lib/TestSuite/TestRunner.ns" />
<arg line="${corelib.dir}/TestSuite/TestRunner.ns" />
</java>
</jacoco:coverage>

Expand All @@ -291,12 +303,12 @@
<arg value="--java-coverage" />
<arg value="jacoco.exec" />
<arg value="-G" />
<arg value="core-lib/TestSuite/TestRunner.ns" />
<arg value="${corelib.dir}/TestSuite/TestRunner.ns" />
</exec>

<exec executable="./som" failonerror="true">
<arg value="-X" />
<arg value="core-lib/TestSuite/TestRunner.ns" />
<arg value="${corelib.dir}/TestSuite/TestRunner.ns" />
</exec>
</target>

Expand Down
14 changes: 7 additions & 7 deletions core-lib/Files.ns
Expand Up @@ -593,7 +593,7 @@ DAMAGE.>> *)
)

public simpleName ^ <String> = (
^ elements last name
^ elements last pattern
)

public charInputStream ^ <CharInputStream> = (
Expand All @@ -606,24 +606,24 @@ DAMAGE.>> *)

public readStream ^ <ExternalReadStream> = (
^ExternalReadStream onDescriptor: (
self open: #read ifFail: [ :err <Exception> |
self error: err
self open: #read ifFail: [ :err <Exception> |
self error: err
]
)
)

public readWriteStream ^ <ExternalReadWriteStream> = (
^ExternalReadWriteStream onDescriptor: (
self open: #readWrite ifFail: [ :err <Exception> |
self error: err
self open: #readWrite ifFail: [ :err <Exception> |
self error: err
]
)
)

public writeStream ^ <ExternalReadWriteStream> = (
^ExternalOutputStream onDescriptor: (
self open: #write ifFail: [ :err <Exception> |
self error: err
self open: #write ifFail: [ :err <Exception> |
self error: err
]
)
)
Expand Down
2 changes: 1 addition & 1 deletion core-lib/Kernel.ns
Expand Up @@ -103,7 +103,7 @@ class Kernel vmMirror: vmMirror = Object <: Value (
public class Class = Object ()
(
(* Allocation *)
public new = ( self error: 'never execute should be:' (* ^ (vmMirror instantiate: self) initialize`new *) )
public new = ( self error: 'Class>>new method should never be executed. Instantiation works differently.' (* ^ (vmMirror instantiate: self) initialize`new *) )
)

public class Metaclass = Class ()()
Expand Down
64 changes: 64 additions & 0 deletions core-lib/TestSuite/ExtensionTests.ns
@@ -0,0 +1,64 @@
(* Testing SOMns' extension mechanism.

SOMns extensions are special jar files that contain primitives.
They are loaded like a normal module and behave the same.
Thus, from the perspective of the user, they are not distinguishable from
other modules.
*)
class ExtensionTests usingPlatform: platform testFramework: minitest = Value (
| private TestContext = minitest TestContext.
private ObjectMirror = platform mirrors ObjectMirror.
private FilePath = platform files FilePath.

private system = platform system.

private jarName = 'extension/build/test-extension.jar'.
private modulePath = (ObjectMirror reflecting: self) classMirror classDefinition filePath.
private jarPath = ((FilePath for: modulePath) containingDirectory / jarName) pattern.
|)(
public class BasicTest = TestContext ()(

private loadModule = (
^ system loadModule: jarName nextTo: self.
)

(* Make sure the test extension has been compiled. *)
public testExtensionJarAvailable = (
assert: (FilePath for: jarPath) exists description: 'The ' + jarName + ' is missing. Please ensure building the extension.'.
)

(* The same as a normal module, loading it returns the class object. *)
public testModuleLoadReturnsClass = (
| module = loadModule new.
mirror = ObjectMirror reflecting: module. |
assert: (mirror className endsWith: jarName).
)

public testModuleMethodsWorking = (
| m = loadModule new. |
assert: m counter equals: 0.
m inc.
assert: m counter equals: 1.
m inc.
m inc.
assert: m counter equals: 3.
)

(* Modules that are loaded multiple times
should be isolated from each other.*)
public testIsolationOfModules = (
| m1 = loadModule new.
m2 = loadModule new. |
assert: m1 counter equals: 0.
assert: m2 counter equals: 0.

m1 inc.
assert: m1 counter equals: 1.
assert: m2 counter equals: 0.

m2 inc. m2 inc.
assert: m1 counter equals: 1.
assert: m2 counter equals: 2.
)
) : ( TEST_CONTEXT = () )
)
2 changes: 1 addition & 1 deletion core-lib/TestSuite/FileTests.ns
Expand Up @@ -157,7 +157,7 @@ class FileTests usingPlatform: platform testFramework: minitest = Value (
assert: cnt = 3.
)

public testMove =(
public testMove = (
| f g |
f:: FilePath for: path + '/tmp'.
f open: #readWrite.
Expand Down
58 changes: 29 additions & 29 deletions core-lib/TestSuite/StreamTests.ns
Expand Up @@ -8,22 +8,22 @@ class StreamTests usingPlatform: platform testFramework: minitest = Value (
private Array = platform kernel Array.
private ObjectMirror = platform mirrors ObjectMirror.
private errorTestMessage = 'test exception 1'.
private Streams = platform streams.
private Files = platform files.
private fdes = Files FileDescriptor.
private filePath = Files FilePath.
|
)(
private streams = platform streams.
private FileDescriptor = platform files FileDescriptor.
private FilePath = platform files FilePath.
private modulePath = (platform mirrors ObjectMirror reflecting: self) classMirror classDefinition filePath.
|)(
public class BasicStreamTests = TestContext (
| path testString|
path:: (filePath currentDirectory / 'tests' / 'streams') pattern.
testString:: 'This is a test String, it is written to a file via a
readWriteStream, and then read and checked to make sure it works'.
)(
| private path = ((FilePath for: modulePath)
containingDirectory
containingDirectory
containingDirectory / 'tests' / 'streams') pattern.
private testString = 'This is a test String, it is written to a file via a readWriteStream, and then read and checked to make sure it works.'.
|)(
public testReadBinary = (
| fp cc b |
(*file contains bytes with increasing values, starting with 1*)
fp:: filePath for: path + '/Binary.blob'.
fp:: FilePath for: path + '/Binary.blob'.
cc:: fp readStream.

(*verify stream is at beginning*)
Expand All @@ -48,26 +48,26 @@ class StreamTests usingPlatform: platform testFramework: minitest = Value (

(*stream is at end*)
assert: cc atEnd.

cc close.
)

public testWriteBinary = (
| fp cc t |
fp:: filePath for: path + '/a.txt'.
fp:: FilePath for: path + '/a.txt'.
cc:: fp writeStream.
1 to: 20 do: [ :i|
cc put: i.
].

cc close.
)


public testReadWriteBinary = (
| fp cc t |
fp:: filePath for: path + '/bin.txt'.

fp:: FilePath for: path + '/bin.txt'.
cc:: fp readWriteStream.

assert: cc position = 0.
Expand All @@ -78,7 +78,7 @@ class StreamTests usingPlatform: platform testFramework: minitest = Value (
cc close.


fp:: filePath for: path + '/bin.txt'.
fp:: FilePath for: path + '/bin.txt'.
cc:: fp readWriteStream.
deny: cc atEnd.
t:: (cc next: (cc size)).
Expand All @@ -90,8 +90,8 @@ class StreamTests usingPlatform: platform testFramework: minitest = Value (

public testReadCharacter = (
| fp cc t |
fp:: filePath for: path + '/Text.t'.
cc:: Streams CharacterReadConverter on: fp readStream.
fp:: FilePath for: path + '/Text.t'.
cc:: streams CharacterReadConverter on: fp readStream.

deny: cc atEnd.

Expand All @@ -103,21 +103,21 @@ class StreamTests usingPlatform: platform testFramework: minitest = Value (

public testReadWriteCharacter = (
| fp cc t |
fp:: filePath for: path + '/test.txt'.
cc:: Streams CharacterInputOutputConverter on: fp readWriteStream.
fp:: FilePath for: path + '/test.txt'.
cc:: streams CharacterInputOutputConverter on: fp readWriteStream.
cc putAll: testString.
cc close.

fp:: filePath for: path + '/test.txt'.
cc:: Streams CharacterInputOutputConverter on: fp readWriteStream.
fp:: FilePath for: path + '/test.txt'.
cc:: streams CharacterInputOutputConverter on: fp readWriteStream.

assert: cc position = 0.
deny: cc atEnd.
assert: cc position equals: 0.
deny: cc atEnd description: 'Stream cannot to be at end when just opend'.

t:: (cc next: (cc size)).
cc close.

assert: t = testString.
assert: t equals: testString.
)

public testCollectionReadStream = (
Expand All @@ -127,7 +127,7 @@ class StreamTests usingPlatform: platform testFramework: minitest = Value (
v append: i.
].

cs:: Streams SeqCltnReadStream on: v.
cs:: streams SeqCltnReadStream on: v.
assert: cs position = 0.
deny: cs atEnd.

Expand All @@ -140,7 +140,7 @@ class StreamTests usingPlatform: platform testFramework: minitest = Value (
public testCollectionReadWriteStream = (
| v cs |
v:: Array new: 20.
cs:: Streams SeqCltnReadWriteStream on: v.
cs:: streams SeqCltnReadWriteStream on: v.
1 to: 20 do: [ :i|
cs put: i.
].
Expand Down
38 changes: 12 additions & 26 deletions core-lib/TestSuite/TestRunner.ns
Expand Up @@ -3,8 +3,11 @@ class TestRunner usingPlatform: platform = (
private system = platform system.
private actors = platform actors.
private minitest = (system loadModule: 'Minitest.ns' nextTo: self) usingPlatform: platform.
|
)(
private modulePath = (platform mirrors ObjectMirror reflecting: self) classMirror classDefinition filePath.

private FilePath = platform files FilePath.
private FilePattern = platform files FilePattern.
|)(

printNameAndDescription: failureOrError = (
failureOrError testCase environment classDeclarationMirror name asString print.
Expand Down Expand Up @@ -81,35 +84,18 @@ class TestRunner usingPlatform: platform = (
)

runAllKnownModules = (
| modules allSuccessful allTestsDonePromise |
modules:: 'ReflectionTests',
'LanguageTests',
'MixinTests',
'CollectionTests',
'DoubleTests',
'IntegerTests',
'StringTests',
'ArrayLiteralTests',
'SymbolTests',
'SystemTests',
'BenchmarkHarnessTests',
'ActorTests',
'ProcessTests',
'RegressionTests',
'ThreadingTests',
'TransactionTests',
'TransferObjectTests',
'ObjectLiteralTests',
'FileTests',
'StreamTests',
'MinitestTests'.
| moduleDir = (FilePath for: modulePath) containingDirectory pattern.
testModules = (FilePattern for: moduleDir + '/*Tests.ns').
modules = testModules paths.
allSuccessful allTestsDonePromise |


allSuccessful:: true.
allTestsDonePromise:: actors async: modules do: [:m |
| testModule |
testModule:: (system loadModule: m + '.ns' nextTo: self)
testModule:: (system loadModule: m pattern)
usingPlatform: platform testFramework: minitest.
m println.
m simpleName println.
(runAllTests: testModule)
whenResolved: [:successful |
allSuccessful:: allSuccessful and: successful.
Expand Down
14 changes: 14 additions & 0 deletions core-lib/TestSuite/extension/.classpath
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="src" path="/com.oracle.truffle.api.dsl"/>
<classpathentry kind="src" path="/BlackDiamonds"/>
<classpathentry kind="src" path="/SOMns"/>
<classpathentry kind="src" path="src_gen">
<attributes>
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="build/classes"/>
</classpath>

0 comments on commit b45069b

Please sign in to comment.