Skip to content

Commit 499c5b1

Browse files
authored
feat: prepare javascript code with new core version (#127)
1 parent 58cf717 commit 499c5b1

File tree

172 files changed

+25331
-14217
lines changed

Some content is hidden

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

172 files changed

+25331
-14217
lines changed

.eslintignore

+5-1
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,13 @@ syntest/
1111
LICENSE*
1212
Dockerfile
1313
NOTICE
14+
commitlint.config.js
15+
link.sh
16+
1417

1518
# The instrumentation files are copied from istanbul (and modified).
1619
# In the future in a big refactor the instrumentation should be redone such that these files dont have to be ignored anymore.
1720
**/instrumentation/Instrumenter.ts
1821
**/instrumentation/VisitState.ts
19-
**/instrumentation/Visitor.ts
22+
**/instrumentation/Visitor.ts
23+
**/instrumentation/source-coverage.ts

.eslintrc.json

+56-10
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,73 @@
11
{
22
"env": {
3-
"es6": true,
3+
"es2021": true,
44
"mocha": true,
55
"node": true
66
},
77
"extends": [
88
"eslint:recommended",
99
"plugin:@typescript-eslint/recommended",
10-
"prettier"
10+
// "plugin:@typescript-eslint/recommended-requiring-type-checking", // TODO later too much work currently
11+
"plugin:unicorn/recommended",
12+
// "plugin:import/recommended", // TODO gives weird errors
13+
"plugin:import/typescript",
14+
"plugin:promise/recommended",
15+
"prettier"//,
16+
// "plugin:sonarjs/recommended" // TODO later too much work currently
1117
],
12-
"parser": "@typescript-eslint/parser",
18+
// "parser": "@typescript-eslint/parser",
1319
"parserOptions": {
14-
"ecmaVersion": 6,
15-
"sourceType": "module"
20+
"ecmaVersion": 2021,
21+
"sourceType": "module"//,
22+
// "project": "./tsconfig.json",
23+
// "tsconfigRootDir": "."
1624
},
17-
"plugins": ["@typescript-eslint", "notice"],
25+
"settings": {
26+
"import/resolver": {
27+
"typescript": true,
28+
"node": true
29+
}
30+
},
31+
"plugins": [
32+
"@typescript-eslint",
33+
"notice",
34+
"unused-imports"
35+
],
1836
"rules": {
19-
"no-fallthrough": "off",
20-
"notice/notice":["error",
37+
// "import/first": "error",
38+
// "import/newline-after-import": "error",
39+
// "import/no-duplicates": "error",
40+
// "import/order": ["error",
41+
// {
42+
// "alphabetize": {
43+
// "order": "asc",
44+
// "caseInsensitive": true
45+
// },
46+
// "newlines-between": "always"
47+
// }
48+
// ],
49+
// "sort-imports": ["error",
50+
// {
51+
// "ignoreDeclarationSort": true,
52+
// "ignoreCase": true
53+
// }
54+
// ],
55+
"notice/notice": [
56+
"error",
2157
{
2258
"templateFile": "./LICENSE.header.ts",
2359
"nonMatchingTolerance": 0.8
24-
}
25-
]
60+
}
61+
],
62+
"unicorn/filename-case": "off",
63+
// "no-unused-vars": "off",
64+
// "@typescript-eslint/no-unused-vars": "off",
65+
// "unused-imports/no-unused-imports": "error",
66+
// "unused-imports/no-unused-vars": [
67+
// "error",
68+
// { "vars": "all", "varsIgnorePattern": "^_", "args": "after-used", "argsIgnorePattern": "^_" }
69+
// ],
70+
"no-fallthrough": "off",
71+
"unicorn/expiring-todo-comments": "off"
2672
}
2773
}

.github/workflows/main-test.yml

+4-3
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,11 @@ jobs:
6161
matrix:
6262
# Collect coverage for all packages and plugins
6363
package:
64-
- libraries/ast-javascript
65-
- libraries/cfg-javascript
64+
- libraries/analysis-javascript
65+
- libraries/ast-visitor-javascript
6666
- libraries/instrumentation-javascript
67-
- libraries/javascript
67+
- libraries/search-javascript
68+
- tools/javascript
6869

6970
steps:
7071
# Download test results

.github/workflows/pr-test.yml

+4-3
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,11 @@ jobs:
9696
matrix:
9797
# Collect coverage for all packages and plugins
9898
package:
99-
- libraries/ast-javascript
100-
- libraries/cfg-javascript
99+
- libraries/analysis-javascript
100+
- libraries/ast-visitor-javascript
101101
- libraries/instrumentation-javascript
102-
- libraries/javascript
102+
- libraries/search-javascript
103+
- tools/javascript
103104

104105
steps:
105106
# Download test results

.prettierignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ node_modules/
44
.*
55
*.jpg
66
NOTICE
7-
Dockerfile
7+
Dockerfile
8+
link.sh

README.md

+32-37
Original file line numberDiff line numberDiff line change
@@ -16,67 +16,62 @@ The common core contains the common interfaces for the code control-flow represe
1616

1717
#### NPM
1818

19-
The simplest way to use syntest-javascript is by installing the [npm package](https://www.npmjs.com/package/syntest/javascript).
19+
The simplest way to use syntest javascript is by installing the following two npm packages: [@syntest/cli](https://www.npmjs.com/package/syntest/cli), [@syntest/javascript](https://www.npmjs.com/package/syntest/javascript).
2020

2121
```bash
22+
$ npm install @syntest/cli
2223
$ npm install @syntest/javascript
2324
```
2425

2526
You can install it in your project as shown in the snippit above or you can install the package globally by using the npm options `-g`.
2627

27-
#### From source
28-
29-
The tool can be used by cloning the project, installing its dependencies, and compiling the TypeScript:
30-
31-
- Clone the projects
28+
## Usage
3229

33-
```bash
34-
$ git clone [email protected]:syntest-framework/syntest-javascript.git
35-
```
30+
To start you need to be in the root of the project folder containing the code you want to create test-cases for. Next, you need to install two dev-dependencies in your project, namely [chai](https://www.npmjs.com/package/chai) and [chai-as-promised](https://www.npmjs.com/package/chai-as-promised). Both are needed to run the tests.
3631

37-
- Install dependencies
32+
Next, you want to run the following command:
3833

3934
```bash
40-
$ cd syntest-javascript; npm install
35+
$ npx syntest init config --modules @syntest/javascript
4136
```
4237

43-
- Build Syntest-javascript
38+
This will create the `.syntest.json` configuration file for you with some pre filled in parameters.
39+
The file should look somewhat like this:
4440

45-
```bash
46-
$ cd syntest-javascript; npm run build
4741
```
48-
49-
You can create a `.syntest.js` file to change the way the tool behaves.
50-
51-
Finally run the tool
52-
53-
```bash
54-
cd <PATH_TO_SYNTEST_JAVASCRIPT>; npm run standalone
42+
{
43+
...,
44+
"target-root-directory": "./express",
45+
"include": [
46+
"./express/lib/**/*.js"
47+
],
48+
"exclude": [],
49+
"modules": [
50+
"@syntest/javascript"
51+
],
52+
"preset": "DynaMOSA"
53+
...
54+
}
5555
```
5656

57-
The results can be found in the `syntest` folder
58-
59-
## Usage
57+
In the above example the most important configuration options are shown.
6058

61-
To start you need to be in the root of the project folder containing the code you want to create test-cases for. Next, you need to install two dev-dependencies in your project, namely [chai](https://www.npmjs.com/package/chai) and [chai-as-promised](https://www.npmjs.com/package/chai-as-promised). Both are needed to run the tests.
59+
- The preset value which decides the algorithms the tool will use.
60+
- The loaded module "@syntest/javascript".
61+
- The target root directory which is the source directory of all the files you want to target.
62+
- The include array where you can specify which files to target.
63+
- The exclude array where you can specify which files to exclude specifically
6264

63-
After installing these dependencies together with the tool, you can run the following example command.
65+
Once these properties are set you can run:
6466

6567
```bash
66-
$ syntest-javascript --target-root-directory="<PATH_TO_YOUR_SOURCE_FOLDER>/src" --total-time=10
68+
$ npx syntest javascript test
6769
```
6870

69-
This will test all javascript code that is contained in the source folder. It will run for 10 seconds.
70-
71-
SynTest-JavaScript is highly configurable and supports a bunch of options and arguments, all of them can be found by providing the `--help` option or `-h` for short. Another way of configuring the tool is by putting a .syntest.js file in the root of your project. The file should have the following structure:
71+
If everything is correct the tool will now start.
72+
The results can be found in the `syntest` folder
7273

73-
```js
74-
module.exports = {
75-
"population-size": 10,
76-
"max-depth": 5,
77-
...
78-
}
79-
```
74+
SynTest-JavaScript is highly configurable and supports a bunch of options and arguments, all of them can be found by providing the `--help` option or `-h` for short. Another way of configuring the tool is through the .syntest.json file in the root of your project.
8075

8176
## Documentation
8277

File renamed without changes.
File renamed without changes.
+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
* Copyright 2020-2023 Delft University of Technology and SynTest contributors
3+
*
4+
* This file is part of SynTest Framework - SynTest Javascript.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
export * from "./lib/ast/AbstractSyntaxTreeFactory";
19+
export * from "./lib/ast/defaultBabelConfig";
20+
21+
export * from "./lib/cfg/ControlFlowGraphFactory";
22+
export * from "./lib/cfg/ControlFlowGraphVisitor";
23+
24+
export * from "./lib/dependency/DependencyFactory";
25+
export * from "./lib/dependency/DependencyVisitor";
26+
27+
export * from "./lib/target/export/Export";
28+
export * from "./lib/target/export/ExportDefaultDeclaration";
29+
export * from "./lib/target/export/ExportFactory";
30+
export * from "./lib/target/export/ExportNamedDeclaration";
31+
export * from "./lib/target/export/ExportVisitor";
32+
export * from "./lib/target/export/ExpressionStatement";
33+
34+
export * from "./lib/target/Target";
35+
export * from "./lib/target/TargetFactory";
36+
export * from "./lib/target/TargetVisitor";
37+
export * from "./lib/target/VisibilityType";
38+
39+
export * from "./lib/type/discovery/element/Element";
40+
export * from "./lib/type/discovery/element/ElementVisitor";
41+
42+
export * from "./lib/type/discovery/object/DiscoveredType";
43+
export * from "./lib/type/discovery/object/ObjectVisitor";
44+
45+
export * from "./lib/type/discovery/relation/Relation";
46+
export * from "./lib/type/discovery/relation/RelationVisitor";
47+
48+
export * from "./lib/type/discovery/TypeExtractor";
49+
50+
export * from "./lib/type/resolving/Type";
51+
export * from "./lib/type/resolving/TypeEnum";
52+
export * from "./lib/type/resolving/TypeModel";
53+
export * from "./lib/type/resolving/TypeModelFactory";
54+
export * from "./lib/type/resolving/InferenceTypeModelFactory";
55+
export * from "./lib/type/resolving/RandomTypeModelFactory";
56+
57+
export * from "./lib/utils/fileSystem";
58+
59+
export * from "./lib/RootContext";

0 commit comments

Comments
 (0)