Skip to content

Commit

Permalink
Inspector integration tests with CDT UI.
Browse files Browse the repository at this point in the history
  • Loading branch information
entlicher committed Nov 16, 2023
1 parent 38d4ba4 commit fa38cec
Show file tree
Hide file tree
Showing 10 changed files with 838 additions and 0 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/cdt-inspect.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Intergation test of CDT with Inspector backend.
name: Weekly CDT Inspector

on:
schedule:
# - cron: "30 2 * * 5" # Friday at 2:30
- cron: "30 12 * * *"

env:
JAVA_HOME: ${{ github.workspace }}/jdk
JDK_VERSION: "latest"
MX_PATH: ${{ github.workspace }}/mx

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: browser-actions/setup-chrome@v1
with:
chrome-version: dev
id: setup-chrome
- name: Checkout oracle/graal
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Checkout oracle/graaljs
uses: actions/checkout@v4
with:
repository: oracle/graaljs
fetch-depth: 1
sparse-checkout: |
graal-js
- name: Checkout graalvm/mx
uses: actions/checkout@v4
with:
repository: graalvm/mx.git
fetch-depth: 1
ref: master
path: ${{ env.MX_PATH }}
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.8'
- name: Fetch LabsJDK
run: |
mkdir jdk-dl
${MX_PATH}/mx --java-home= fetch-jdk --jdk-id labsjdk-ce-${JDK_VERSION} --to jdk-dl --alias ${JAVA_HOME}
- run: |
echo Installed chromium version: ${{ steps.setup-chrome.outputs.chrome-version }}
${{ steps.setup-chrome.outputs.chrome-path }} --version
cd ${{ github.workspace }}/graal/vm
${MX_PATH}/mx --dy /tools,graal-js build
cd tests/gh_workflows/CDTInspectorTest
mvn -q compile
mvn -q exec:java -Dexec.args="${{ github.workspace }}/graal/sdk/latest_graalvm_home/bin/js scripts/StepTest.js ${{ steps.setup-chrome.outputs.chrome-path }}"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,4 @@ visualizer/IdealGraphVisualizer/nbplatform/
/.src-rev
*.interp
*.tokens
/vm/tests/gh_workflows/CDTInspectorTest/target/
31 changes: 31 additions & 0 deletions vm/tests/gh_workflows/CDTInspectorTest/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<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>
<groupId>com.oracle.truffle.tools.chromeinspector.workflowtest</groupId>
<artifactId>CDTInspectorTest</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-api</artifactId>
<version>4.15.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-chrome-driver</artifactId>
<version>4.15.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-support</artifactId>
<version>4.15.0</version>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<exec.mainClass>com.oracle.truffle.tools.chromeinspector.workflowtest.Test</exec.mainClass>
</properties>
</project>
32 changes: 32 additions & 0 deletions vm/tests/gh_workflows/CDTInspectorTest/scripts/StepTest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
* ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/

// Finds the count of numbers that are smaller than the provided one.

var data = [2, 3, 10, 1, 5, 20, 8, 18, 12, 30];

function binarySearch(array, element) {
let i1 = 0;
let i2 = array.length - 1;
while (i1 < i2) {
let i = (i1 + i2) >> 1;
let diff = array[i] - element;
if (diff > 0) {
i2 = i;
} else if (diff < 0) {
i1 = i;
} else {
return i;
}
}
return i1;
}

data = data.sort(function(a,b){return a - b});

var index12 = binarySearch(data, 12);
var index8 = binarySearch(data, 8);
print('Index of element 12 is: ' + index12);
print('Index of element 8 is: ' + index8);
85 changes: 85 additions & 0 deletions vm/tests/gh_workflows/CDTInspectorTest/scripts/StepTest.js.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
Opened file: StepTest.js
Stack (1)
:program StepTest.js:8
Scope (3)
Local
this : Object global{Object: function Object() {
global Global
Stack (1)
:program StepTest.js:27
Scope (3)
Local
this : Object global{Object: function Object() {
global Global
Stack (1)
:program StepTest.js:29
Scope (3)
Local
this : Object global{Object: function Object() {
global Global
Stack (2)
binarySearch StepTest.js:11
:program StepTest.js:29
Scope (5)
Local
this : Object global{Object: function Object() {
array : \(10\) \[1, 2, 3, 5, 8,.*
element : 12
global Global
Stack (2)
binarySearch StepTest.js:12
:program StepTest.js:29
Scope (6)
Local
this : Object global{Object: function Object() {
array : \(10\) \[1, 2, 3, 5, 8,.*
element : 12
i1 : 0
global Global
Stack (2)
binarySearch StepTest.js:13
:program StepTest.js:29
Scope (7)
Local
this : Object global{Object: function Object() {
array : \(10\) \[1, 2, 3, 5, 8,.*
element : 12
i1 : 0
i2 : 9
global Global
Stack (2)
binarySearch StepTest.js:16
:program StepTest.js:29
Scope (10)
Block
diff : -4
i : 4
Local
this : Object global{Object: function Object() {
array : \(10\) \[1, 2, 3, 5, 8,.*
element : 12
i1 : 0
i2 : 9
global Global
Stack (2)
binarySearch StepTest.js:18
:program StepTest.js:29
Scope (10)
Block
diff : -4
i : 4
Local
this : Object global{Object: function Object() {
array : \(10\) \[1, 2, 3, 5, 8,.*
element : 12
i1 : 0
i2 : 9
global Global
Stack (1)
:program StepTest.js:29
Scope (3)
Local
this : Object global{Object: function Object() {
global Global
Index of element 12 is: 6
Index of element 8 is: 4
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.oracle.truffle.tools.chromeinspector.workflowtest;

import java.time.Duration;
import java.util.Objects;

public abstract class AbstractTest {

protected static final Duration TIMEOUT = Duration.ofSeconds(5);

protected static void assertTrue(boolean condition, String message) {
if (!condition) {
fail(message);
}
}

protected static void assertFalse(boolean condition, String message) {
assertTrue(!condition, message);
}

protected static void assertNotNull(Object object, String message) {
assertTrue(object != null, message);
}

protected static void assertEquals(Object expected, Object actual, String message) {
Objects.requireNonNull(expected);
if (expected.equals(actual)) {
return;
}
String cmpMessage = "Expected: '" + expected + "' but was: '" + actual + "'";
fail(message == null ? cmpMessage : message + " " + cmpMessage);
}

protected static void fail(String message) {
throw (message != null) ? new AssertionError(message) : new AssertionError();
}
}
Loading

0 comments on commit fa38cec

Please sign in to comment.