Skip to content

Commit ac58c18

Browse files
author
Aishwarya Jagarapu
committed
fix workflow failures 1/n
1 parent 0aff5c4 commit ac58c18

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+5355
-4
lines changed

.github/workflows/macosci.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ jobs:
2121
path: ~/.m2
2222
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
2323
restore-keys: ${{ runner.os }}-m2
24-
- name: Build Java P runtime
25-
run: mvn clean compile package -f Src/PRuntimes/PExRuntime/pom.xml
2624
- name: Build
2725
run: dotnet build --configuration Release
2826
- name: Test

.github/workflows/ubuntuci.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ jobs:
2121
path: ~/.m2
2222
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
2323
restore-keys: ${{ runner.os }}-m2
24-
- name: Build Java P runtime
25-
run: mvn clean compile package -f Src/PRuntimes/PExRuntime/pom.xml
2624
- name: Build
2725
run: dotnet build --configuration Release
2826
- name: Test
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
### IntelliJ IDEA ###
2+
out/
3+
!**/src/main/**/out/
4+
!**/src/test/**/out/
5+
6+
### Eclipse ###
7+
.apt_generated
8+
.classpath
9+
.factorypath
10+
.project
11+
.settings
12+
.springBeans
13+
.sts4-cache
14+
bin/
15+
!**/src/main/**/bin/
16+
!**/src/test/**/bin/
17+
18+
### NetBeans ###
19+
/nbproject/private/
20+
/nbbuild/
21+
/dist/
22+
/nbdist/
23+
/.nb-gradle/
24+
25+
### VS Code ###
26+
.vscode/
27+
28+
### Mac OS ###
29+
.DS_Store
30+
31+
### Maven ###
32+
target/
33+
34+
### Log4J ###
35+
*.log
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Java PRT
2+
3+
This project is the Java runtime for executing monitors compiled by the P Java
4+
backend. It reimplements a subset of the Coyote state machine runtime.
5+
6+
## Building
7+
8+
```
9+
$ mvn compile
10+
```
11+
12+
## Testing
13+
14+
```
15+
$ mvn test
16+
```
17+
18+
## Installation
19+
20+
This builds and places the compiled JAR in your local Maven repository, which
21+
by default is located at `~/.m2/`.
22+
23+
```
24+
$ mvn install
25+
...
26+
[INFO] Installing target/PJavaRuntime-1.0-SNAPSHOT.jar to /Users/nathta/.m2/repository/p/runtime/PJavaRuntime/1.0-SNAPSHOT/PJavaRuntime-1.0-SNAPSHOT.jar
27+
[INFO] Installing pom.xml to /Users/nathta/.m2/repository/p/runtime/PJavaRuntime/1.0-SNAPSHOT/PJavaRuntime-1.0-SNAPSHOT.pom
28+
```

Src/PRuntimes/PJavaRuntime/pom.xml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>p.runtime</groupId>
8+
<artifactId>PJavaRuntime</artifactId>
9+
<version>${revision}</version>
10+
11+
<name>Java runtime for the P programming language</name>
12+
<url>https://github.com/p-org/P</url>
13+
14+
<licenses>
15+
<license>
16+
<name>MIT License</name>
17+
<url>https://spdx.org/licenses/MIT.html</url>
18+
</license>
19+
</licenses>
20+
21+
<dependencies>
22+
<dependency>
23+
<groupId>org.junit.jupiter</groupId>
24+
<artifactId>junit-jupiter</artifactId>
25+
<version>5.8.2</version>
26+
<scope>test</scope>
27+
</dependency>
28+
<dependency>
29+
<groupId>org.apache.logging.log4j</groupId>
30+
<artifactId>log4j-api</artifactId>
31+
<version>2.17.2</version>
32+
</dependency>
33+
<dependency>
34+
<groupId>org.apache.logging.log4j</groupId>
35+
<artifactId>log4j-core</artifactId>
36+
<version>2.17.2</version>
37+
</dependency>
38+
<dependency>
39+
<groupId>org.apache.logging.log4j</groupId>
40+
<artifactId>log4j-layout-template-json</artifactId>
41+
<version>2.17.2</version>
42+
</dependency>
43+
<dependency>
44+
<groupId>org.jacoco</groupId>
45+
<artifactId>jacoco-maven-plugin</artifactId>
46+
<version>0.8.8</version>
47+
</dependency>
48+
</dependencies>
49+
50+
<build>
51+
<plugins>
52+
<plugin>
53+
<groupId>org.jacoco</groupId>
54+
<artifactId>jacoco-maven-plugin</artifactId>
55+
<version>0.8.8</version>
56+
<executions>
57+
<execution>
58+
<goals>
59+
<goal>prepare-agent</goal>
60+
</goals>
61+
</execution>
62+
<execution>
63+
<id>report</id>
64+
<phase>test</phase>
65+
<goals>
66+
<goal>report</goal>
67+
</goals>
68+
</execution>
69+
</executions>
70+
</plugin>
71+
</plugins>
72+
</build>
73+
<properties>
74+
<maven.compiler.source>11</maven.compiler.source>
75+
<maven.compiler.target>11</maven.compiler.target>
76+
<log4j2.configurationFile>${project.basedir}/src/main/resources/log4j2.xml</log4j2.configurationFile>
77+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
78+
<revision>1.0-SNAPSHOT</revision>
79+
</properties>
80+
81+
</project>
Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
package parsers;
2+
3+
import java.util.ArrayList;
4+
import java.util.List;
5+
import java.util.regex.Pattern;
6+
import java.util.stream.Stream;
7+
8+
public class PTraceParserUtils {
9+
private static final String PREFIX = "<SendLog>";
10+
11+
private static final String evtRegex = "sent event '(\\w+) with payload \\((.+)\\)' to";
12+
public static final Pattern evtPattern = Pattern.compile(evtRegex);
13+
14+
private static boolean sendLogFilter(String msg) {
15+
return msg.startsWith(PREFIX);
16+
}
17+
18+
/**
19+
* Produces the given stream of log lines, removing the ones that do
20+
* not originate from the SendLog source.
21+
* @param s
22+
* @return
23+
*/
24+
public static Stream<String> FilterSendLogs(Stream<String> s){
25+
return s.filter(PTraceParserUtils::sendLogFilter);
26+
}
27+
28+
29+
/**
30+
* These routines help convert serialised data in the form emitted by the C# runtime,
31+
* which all inherit from `PLang.CSharpRuntime.PrtType`. Should any PrtType's `.toString()`
32+
* method be changed, these conversion functions may break.
33+
*/
34+
public static class Conversions {
35+
private static final String tupleDelimiter = ","; /* Note the lack of space, vis a vis named tuples */
36+
private static final String namedTupleDelimiter = ", ";
37+
38+
/**
39+
* Given a serialized named tuple of the form `<k1:v1, k2:v2, ... kn:vn, >`, return an array
40+
* of Strings containing all the key-value pairs. (Note the trailing ", " after the final
41+
* key-value pair[1]; the suprious empty final element is truncated from the final result array.)
42+
*
43+
* [1]: https://github.com/p-org/P/blob/master/Src/PRuntimes/PCSharpRuntime/Values/PrtTuple.cs#L191-L191
44+
* @param token The string representation of a k-ary named tuple
45+
* @return An array of `k` elements, containing each of the colon-delimited key-value pairs.
46+
*/
47+
public static List<String> namedTupleToKVPairs(String token) {
48+
if (token.charAt(0) != '<' || !token.endsWith(", >")) {
49+
throw new RuntimeException(String.format("Token \"%s\" does not appear to be a named tuple?", token));
50+
}
51+
token = token.substring(1, token.length() - 3); // Eat the open brace and trailing comma/space/closing brace.
52+
return splitCommasOutsideStrings(token, ", ");
53+
}
54+
55+
/**
56+
* Given a serialised tuple of the form `<v1,v2,v3...vn,>`, return an array of Strings
57+
* containing all the values. (Notice the trailing "," after the final value[1]; this spurious
58+
* element is truncated from the final result.)
59+
*
60+
* [1]: https://github.com/p-org/P/blob/master/Src/PRuntimes/PCSharpRuntime/Values/PrtTuple.cs#L95-L95
61+
* @param token
62+
* @return
63+
*/
64+
public static List<String> tupleToValues(String token) {
65+
if (token.charAt(0) != '<' || !token.endsWith(",>")) {
66+
throw new RuntimeException(String.format("Token \"%s\" does not appear to be a tuple?", token));
67+
}
68+
token = token.substring(1, token.length() - 2); // Eat the open brace and trailing comma/closing brace
69+
return splitCommasOutsideStrings(token, ",");
70+
}
71+
72+
/**
73+
* Given a key-value pair of the form "key:value", where value
74+
* is an Integer, extract the int.
75+
* @param kv
76+
* @return
77+
*/
78+
public static int kvPairToInt(String kv) {
79+
return Integer.valueOf(kv.split(":")[1]);
80+
}
81+
82+
/**
83+
* Given a key-value pair of the form "key:value", where value
84+
* is a long, extract the long.
85+
* @param kv
86+
* @return
87+
*/
88+
public static long kvPairToLong(String kv) {
89+
return Long.valueOf(kv.split(":")[1]);
90+
}
91+
92+
/**
93+
* Given a key-value pair of the form "key:MachineName(value)", where value
94+
* is a long and MachineName is an arbitrary identifier, extract the long.
95+
* @param kv
96+
* @return
97+
*/
98+
public static long kvPairToMachineId(String kv) {
99+
int openParen = kv.indexOf("(");
100+
int closeParen = kv.indexOf(")");
101+
return Long.valueOf(kv.substring(openParen + 1, closeParen));
102+
}
103+
104+
/**
105+
* Given a key-value pair of the form "key:value", where value
106+
* is a float, extract the long.
107+
* @param kv
108+
* @return
109+
*/
110+
public static float kvPairToFloat(String kv) {
111+
return Float.valueOf(kv.split(":")[1]);
112+
}
113+
114+
/**
115+
* Given a key-value pair of the form "key:value", where value
116+
* is an enumerated value, extract it.
117+
*/
118+
public static int kvPairToEnumVal(String kv) {
119+
// Internally, the integer representation will already have been written out,
120+
// so this is equivalent to parsing an int out.
121+
return kvPairToInt(kv);
122+
}
123+
124+
/**
125+
* Splits `s` according to its occurrences of `delimiter`, such that the delimiters
126+
* do not fall inside a quoted string. This method assumes that there are no dangling
127+
* quotes (i.e. there are an even number of occurrences of /[^\\]"/ in s.
128+
*
129+
* @param s
130+
* @return
131+
*/
132+
private static List<String> splitCommasOutsideStrings(String str, String delimiter)
133+
{
134+
ArrayList<String> ret = new ArrayList<>();
135+
boolean inQuotedString = (str.charAt(0) == '"');
136+
137+
StringBuilder currentStr = new StringBuilder(str.substring(0, 1));
138+
139+
// Note the slightly-pedestrian way of writing this. The alternative was to write
140+
// a gnarly regex using negative lookahead assertions (which would be O(n^2) anyway)
141+
// or taking a major dependency on something like Apache Commons.
142+
for (int i = 1; i < str.length(); i++) {
143+
if (!inQuotedString && str.substring(i).startsWith(delimiter)) {
144+
ret.add(currentStr.toString());
145+
currentStr = new StringBuilder();
146+
i += delimiter.length() - 1;
147+
continue;
148+
}
149+
150+
char prev = str.charAt(i - 1);
151+
char curr = str.charAt(i);
152+
153+
if (curr == '"' && prev != '\\') {
154+
inQuotedString = !inQuotedString;
155+
}
156+
currentStr.append(curr);
157+
}
158+
if (currentStr.length() > 0) {
159+
ret.add(currentStr.toString());
160+
}
161+
return ret;
162+
}
163+
164+
/**
165+
* Given a key-value pair of the form "key:value", where value is a string, extract it.
166+
* Note: https://github.com/p-org/P/issues/447 is an issue here.
167+
*/
168+
public static String kvPairToString(String kv) {
169+
return kv.split(":", 2)[1];
170+
}
171+
}
172+
}

0 commit comments

Comments
 (0)