Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

env:
JAVA_VERSION: 21

jobs:
test:
strategy:
fail-fast: false
matrix:
node-version: ['22.x']
os: [ubuntu-latest, windows-2022, macos-latest]

runs-on: ${{ matrix.os }}

steps:
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: ${{ env.JAVA_VERSION }}

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
registry-url: 'https://registry.npmjs.org/'

- name: Checkout repository
uses: actions/checkout@v4

- name: Install dependencies
run: npm install

- name: Build the project
run: npm run build

- name: Run tests
run: npm run test
11 changes: 10 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
import { weaverConfig } from "@specs-feup/clava/code/WeaverConfiguration.js";

const config = {
preset: "ts-jest/presets/default-esm",
transform: {
"^.+\\.tsx?$": [
"ts-jest",
{
useESM: true,
tsconfig: "tsconfig.jest.json",
},
],
},
extensionsToTreatAsEsm: [".ts"],
testEnvironment: "@specs-feup/lara/jest/jestEnvironment.js",
testEnvironmentOptions: {
weaverConfig,
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"clean": "rm -rf node_modules package-lock.json dist/ woven_code/ output/",
"lint": "eslint .",
"docs": "typedoc",
"test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --runInBand --detectOpenHandles --forceExit",
"bundle": "npm run build && pkg . --targets node18-linux-x64,node18-macos-x64,node18-win-x64 --out-path bin",
"simple:appdump": "clava dist/test/simple-use-cases/AppDumping.js -- clang inputs/edgedetect-transformed/",
"simple:transflow": "clava dist/test/simple-use-cases/CodeTransformationFlow.js -- clang inputs/edgedetect/",
Expand Down
80 changes: 80 additions & 0 deletions test/ExtendedTaskGraph.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import { readFileSync } from "node:fs";
import JavaTypes from "@specs-feup/lara/api/lara/util/JavaTypes.js";
import Weaver from "@specs-feup/lara/api/weaver/Weaver.js";
import { ExtendedTaskGraphAPI } from "../src/api/ExtendedTaskGraphAPI.js";
import { GenFlowConfig } from "../src/api/GenFlowConfig.js";
import { TransFlowConfig } from "../src/api/TransFlowConfig.js";

const source = readFileSync(
"inputs/cluster-scenario/ClusterScenario.cpp",
"utf8",
);

function registerSourceCode(code: string): void {
beforeEach(() => {
const javaWeaver = Weaver.getWeaverEngine();
const javaDatastore = javaWeaver.getData().get();

javaWeaver.run(["ClusterScenario.cpp"], [code], javaDatastore);
});

afterEach(() => {
Weaver.getWeaverEngine().end();
});

afterAll(() => {
const javaWeaver = Weaver.getWeaverEngine();
const javaDatastore = javaWeaver.getData().get();

javaDatastore.set(
JavaTypes.LaraiKeys.WORKSPACE_FOLDER,
JavaTypes.FileList.newInstance(),
);
javaWeaver.run(javaDatastore);
});
}

describe("ExtendedTaskGraphAPI workflows", () => {
registerSourceCode(source);

test("runs the code transformation flow", () => {
const config = new TransFlowConfig();
config.dumpAST = false;
config.dumpCallGraph = false;
config.doSubsetInterTransforms = false;
config.doSubsetTaskTransforms = false;

const api = new ExtendedTaskGraphAPI(
"start",
"output/tests",
"transformation-flow",
);

expect(api.runCodeTransformationFlow(config)).toBe(true);
});

test("builds a task graph from transformed code", () => {
const api = new ExtendedTaskGraphAPI(
"start",
"output/tests",
"task-graph-flow",
);

const transConfig = new TransFlowConfig();
transConfig.dumpAST = false;
transConfig.dumpCallGraph = false;
transConfig.transformRecipe = [];

expect(api.runCodeTransformationFlow(transConfig)).toBe(true);

const config = new GenFlowConfig();
config.dumpGraph = false;
config.gatherMetrics = false;

const taskGraph = api.runTaskGraphGenerationFlow(config);

expect(taskGraph).not.toBeNull();
expect(taskGraph!.getTasks().length).toBeGreaterThan(0);
expect(taskGraph!.getTaskByName("fizzbuzz")).toBeDefined();
});
});
3 changes: 3 additions & 0 deletions tsconfig.jest.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"isolatedModules": true
},
"include": ["**/*.spec.ts", "**/*.test.ts"],
"exclude": ["node_modules"]
}
Loading