Skip to content

Commit

Permalink
update fct test runner
Browse files Browse the repository at this point in the history
  • Loading branch information
AFine-gs committed Nov 14, 2024
1 parent c39700a commit 3ba8049
Show file tree
Hide file tree
Showing 7 changed files with 192 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ import meta::core::runtime::*;
import meta::pure::mapping::*;
import meta::pure::test::fct::*;

Profile meta::pure::test::fct::FCT
{
stereotypes : [test, adapter];
}

function

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ // Copyright 2023 Goldman Sachs
~ //
~ // Licensed 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.
-->

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.finos.legend.engine</groupId>
<artifactId>legend-engine-core-testable</artifactId>
<version>4.65.4-SNAPSHOT</version>
</parent>
<name>Legend Engine - Testable - FCT</name>
<artifactId>legend-engine-test-fct</artifactId>

<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.finos.legend.pure</groupId>
<artifactId>legend-pure-m4</artifactId>
</dependency>
<dependency>
<groupId>org.finos.legend.pure</groupId>
<artifactId>legend-pure-m3-core</artifactId>
</dependency>
<dependency>
<groupId>org.finos.legend.pure</groupId>
<artifactId>legend-pure-runtime-java-engine-compiled</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.collections</groupId>
<artifactId>eclipse-collections-api</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* // Copyright 2023 Goldman Sachs
* //
* // Licensed 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.
*/

package org.finos.legend.engine.test.fct;

import junit.framework.TestSuite;
import org.eclipse.collections.api.list.MutableList;
import org.eclipse.collections.api.map.MutableMap;
import org.finos.legend.pure.m3.execution.ExecutionSupport;
import org.finos.legend.pure.m3.execution.test.PureTestBuilder;
import org.finos.legend.pure.m3.execution.test.TestCollection;
import org.finos.legend.pure.m3.navigation.ProcessorSupport;
import org.finos.legend.pure.m3.navigation.profile.Profile;
import org.finos.legend.pure.m4.coreinstance.CoreInstance;
import org.finos.legend.pure.runtime.java.compiled.testHelper.PureTestBuilderCompiled;

import static org.finos.legend.pure.m3.execution.test.TestCollection.collectTests;

public class FCTTestSuitBuilder
{
public static TestSuite buildFCTTestSuiteWithExecutorFunction(TestCollection collection, MutableMap<String, String> exclusions, String function, ExecutionSupport executionSupport)
{
PureTestBuilder.F2<CoreInstance, MutableList<Object>, Object> testExecutor = (a, b) ->
PureTestBuilderCompiled.executeFn(a, function, exclusions, executionSupport, b);
TestSuite suite = new TestSuite();
suite.addTest(PureTestBuilder.buildSuite(collection, testExecutor, executionSupport));
return suite;
}

public static TestCollection buildFCTTestCollection(String path, ProcessorSupport processorSupport)
{
return collectTests(path, processorSupport, (node) ->
{
return isFCTTest(node, processorSupport);
});
}

public static boolean isFCTTest(CoreInstance node, ProcessorSupport processorSupport)
{
return Profile.hasStereotype(node, "meta::pure::test::fct::FCT", "test", processorSupport);
}

}
2 changes: 2 additions & 0 deletions legend-engine-core/legend-engine-core-testable/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,7 @@
<module>legend-engine-testable-http-api</module>
<module>legend-engine-execution-test-data-generation</module>
<module>legend-engine-execution-test-data-generation-api</module>
<module>legend-engine-test-fct</module>

</modules>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,11 @@
<artifactId>legend-pure-m2-dsl-path-grammar</artifactId>
<version>${legend.pure.version}</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.finos.legend.pure</groupId>-->
<!-- <artifactId>legend-pure-m2-dsl-tds-pure</artifactId>-->
<!-- <version>${legend.pure.version}</version>-->
<!-- </dependency>-->
<dependency>
<groupId>org.finos.legend.pure</groupId>
<artifactId>legend-pure-m2-dsl-tds-pure</artifactId>
<version>${legend.pure.version}</version>
</dependency>

<dependency>
<groupId>org.finos.legend.pure</groupId>
Expand Down Expand Up @@ -280,10 +280,10 @@
<artifactId>legend-engine-pure-functions-relation-pure</artifactId>
<scope>runtime</scope>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.finos.legend.pure</groupId>-->
<!-- <artifactId>legend-pure-m2-dsl-tds-pure</artifactId>-->
<!-- </dependency>-->
<dependency>
<groupId>org.finos.legend.pure</groupId>
<artifactId>legend-pure-m2-dsl-tds-pure</artifactId>
</dependency>

<dependency>
<groupId>org.finos.legend.engine</groupId>
Expand Down Expand Up @@ -436,6 +436,16 @@
<artifactId>legend-engine-pure-runtime-java-extension-shared-functions-planExecution</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.finos.legend.engine</groupId>
<artifactId>legend-engine-test-framework</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.finos.legend.engine</groupId>
<artifactId>legend-engine-test-fct</artifactId>
<scope>test</scope>
</dependency>

<!-- TEST -->
</dependencies>
Expand Down Expand Up @@ -469,7 +479,7 @@
</execution>
</executions>
</plugin>
</plugins>
</plugins>
</build>
</profile>
</profiles>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* // Copyright 2023 Goldman Sachs
* //
* // Licensed 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.
*/

package org.finos.legend.pure.code.core.relational;

import junit.framework.Test;
import org.eclipse.collections.api.factory.Lists;
import org.eclipse.collections.api.map.MutableMap;
import org.eclipse.collections.impl.factory.Maps;
import org.finos.legend.engine.test.fct.FCTTestSuitBuilder;
import org.finos.legend.pure.m3.execution.test.TestCollection;
import org.finos.legend.pure.runtime.java.compiled.execution.CompiledExecutionSupport;

import static org.finos.legend.engine.test.fct.FCTTestSuitBuilder.buildFCTTestCollection;
import static org.finos.legend.engine.test.shared.framework.PureTestHelperFramework.*;

public class Test_Pure_Relational_FCT
{
public static Test suite()
{
CompiledExecutionSupport support = getClassLoaderExecutionSupport();
MutableMap<String,String> exclusions = Maps.mutable.empty();

TestCollection collection = buildFCTTestCollection("meta::relational::tests::mapping::association::embedded", support.getProcessorSupport());
return wrapSuite(
() -> true,
() -> FCTTestSuitBuilder.buildFCTTestSuiteWithExecutorFunction(collection, exclusions,"meta::pure::test::fct::executeWrapper_FunctionDefinition_1__TestParameters_1__ExecuteResult_1_", support),
() -> false,
Lists.mutable.empty()
);
}

}
7 changes: 6 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@

<properties>
<!-- Legend -->
<legend.pure.version>5.22.2-SNAPSHOT</legend.pure.version>
<legend.pure.version>5.22.1</legend.pure.version>
<legend.shared.version>0.25.7</legend.shared.version>
<legend.web-application.version>12.59.0</legend.web-application.version>

Expand Down Expand Up @@ -2371,6 +2371,11 @@
<artifactId>legend-engine-testable-http-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.finos.legend.engine</groupId>
<artifactId>legend-engine-test-fct</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.finos.legend.engine</groupId>
<artifactId>legend-engine-test-framework</artifactId>
Expand Down

0 comments on commit 3ba8049

Please sign in to comment.