Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrated with the latest enre-test framework #58

Merged
merged 9 commits into from
Jan 22, 2024
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
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "enre-java-test"]
path = enre-java-test
url = git@github.com:ba1man/enre-java-test.git
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,38 @@ $java -jar enre_java.jar java ...\frameworks\base base -a <aidl-path>
# in windows platform
$java -jar enre_java.jar java ...\frameworks\base base -d ...\base
```

## Testing

### Prerequests

* Node.js 16~18

### Steps

ENRE-java is integrated with [ENRE-test](https://github.com/xjtu-enre/enre-test). All you need to do for performing unit test is running the following script:

```sh
./scripts/gen_tests.sh
```

or (In case you're using Windows platform):

```cmd
scripts\gen_tests.bat
```

Test cases and `JUnit` java files will be generated under directory `src/test/resources` and `src/test/java/client`.

you can execute all `JUnit` test cases by executing the following command in the project directory:

```sh
mvn clean test
```

or execute specific test case by passing class name:

```sh
mvn clean test -DTest=AClassDefinesAFieldTest
```

10 changes: 5 additions & 5 deletions docs/entity/Class.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,11 @@ name: Anonymous Class Declaration
entity:
type: Class
items:
- name: <Anonymous as="Class">
qualified: Foo.doThings.<Anonymous as="Class">
- name: <Anon Class>
qualified: Foo.doThings.<Anon Class>
loc: 13:13
- name: <Anonymous as="Class">
qualified: Foo.doThings.<Anonymous as="Class">
- name: <Anon Class>
qualified: Foo.doThings.<Anon Class>
loc: 19:13

```
```
2 changes: 1 addition & 1 deletion docs/entity/Method.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ name: LambdaMethod Declaration
entity:
type: Method
items:
- name: <Anonymous as="Method">
- name: <Anon Method>
loc: 3:33:0
Lambda: true
```
Expand Down
1 change: 1 addition & 0 deletions enre-java-test
Submodule enre-java-test added at 9495d9
15 changes: 15 additions & 0 deletions scripts/gen_tests.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@echo off

SET ENRE_REPO=../
SET TEST_REPO=%CD%\..\enre-java-test
git "submodule" "init"
git "submodule" "update"
pushd "%TEST_REPO%" && git "checkout" "main" && popd
IF "-d" "./%TEST_REPO%" (
[ "-d" "./%TEST_REPO%/docs" "]" && DEL /S "./%TEST_REPO%/docs"
[ "-d" "./%TEST_REPO%/tests" "]" && DEL /S "./%TEST_REPO%/tests"
COPY "%ENRE_REPO%\docs" "%TEST_REPO%\docs"
[ "!" "-d" "%ENRE_REPO%/src/test/java/client" "]" && mkdir "-vp" "%ENRE_REPO%/src/test/java/client"
[ "!" "-d" "%ENRE_REPO%/src/test/resources" "]" && mkdir "-vp" "%ENRE_REPO%/src/test/resources"
pushd "%TEST_REPO%" && npm "install" && node "--experimental-specifier-resolution=node" "%TEST_REPO%/src/index.js" && popd && COPY "%TEST_REPO%/tests/suites/*.java" "%ENRE_REPO%/src/test/java/client/" && COPY "%TEST_REPO%/tests/cases" "%ENRE_REPO%/src/test/resources/"
)
27 changes: 27 additions & 0 deletions scripts/gen_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#! /usr/bin/env bash

ENRE_REPO="./"
TEST_REPO="./enre-java-test"

git submodule init
git submodule update

pushd $TEST_REPO && \
git pull origin main && \
git checkout main && \
popd

if [ -d "./$TEST_REPO" ]; then
[ -d "./$TEST_REPO/docs" ] && rm -rfv "./$TEST_REPO/docs"
[ -d "./$TEST_REPO/tests" ] && rm -rfv "./$TEST_REPO/tests"
cp -rv $ENRE_REPO/docs $TEST_REPO/docs
[ ! -d "$ENRE_REPO/src/test/java/client" ] && mkdir -vp "$ENRE_REPO/src/test/java/client"
[ ! -d "$ENRE_REPO/src/test/resources" ] && mkdir -vp "$ENRE_REPO/src/test/resources"
pushd "$TEST_REPO" && \
npm install && \
node --experimental-specifier-resolution=node "./src/index.js" && \
popd && \
cp -rv $TEST_REPO/tests/suites/*.java "$ENRE_REPO/src/test/java/client/" && \
cp -rv "$TEST_REPO/tests/cases" "$ENRE_REPO/src/test/resources/"
fi

118 changes: 0 additions & 118 deletions test/README.md

This file was deleted.

107 changes: 0 additions & 107 deletions test/basic.ts

This file was deleted.

14 changes: 0 additions & 14 deletions test/cli.ts

This file was deleted.

40 changes: 0 additions & 40 deletions test/deploy.sh

This file was deleted.

Loading