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

Prepare javascript code with new core version #127

Merged
merged 36 commits into from May 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
718c022
feat: prepare javascript code with new core version
dstallenberg Mar 9, 2023
974efa5
fix: update launcher
dstallenberg Mar 10, 2023
bfb0b16
chore: update to new version of the syntest core
dstallenberg Mar 13, 2023
9591284
fix: add final update
dstallenberg Mar 20, 2023
ec92f4d
feat: repair export visitor and test everything
dstallenberg Mar 29, 2023
61ff0f5
feat: repair export visitor and test everything
dstallenberg Mar 29, 2023
34c7407
feat: repair export visitor and test everything
dstallenberg Mar 29, 2023
1763184
feat: repair export visitor and test everything
dstallenberg Mar 29, 2023
9f3a673
feat: repair export visitor and test everything
dstallenberg Mar 29, 2023
31d3a80
feat: finalize target visitor
dstallenberg Mar 29, 2023
454fc64
fix: remove some old code
dstallenberg Mar 29, 2023
6fce480
feat: implement loops and if statements in the new cfg generator
dstallenberg Apr 3, 2023
e5f4e6e
feat: implement switch case in cfg
dstallenberg Apr 4, 2023
9c36a80
fix: refactor type visitors
dstallenberg Apr 6, 2023
f6ab4b6
feat: update to new version of core
dstallenberg Apr 11, 2023
8495a2a
fix: fix launcher and module
dstallenberg Apr 11, 2023
1f93b80
fix: repair most bugs
dstallenberg Apr 12, 2023
753baa3
fix: connect type resolving
dstallenberg Apr 12, 2023
98a9b68
feat: fix alot of bugs
dstallenberg Apr 19, 2023
7fe3945
feat: fix circular type dependencies problems and bug with loop branc…
dstallenberg Apr 20, 2023
6637256
fix: metadata undefined bug
dstallenberg Apr 20, 2023
d0ce85f
fix: make sure that the argument of a return statement points to the …
dstallenberg Apr 20, 2023
19fbdc9
fix: allow for single location branches (default-arg branches)
dstallenberg Apr 20, 2023
ac6f446
fix: if right side of in operator is undefined we should return dista…
dstallenberg Apr 20, 2023
21ea824
fix: for entire lodash library
dstallenberg Apr 21, 2023
a0cb065
fix: update packages
dstallenberg Apr 22, 2023
32ff2ee
ci: correct packages in ci scripts
dstallenberg Apr 22, 2023
eecdd61
feat: repair express and commanderjs
dstallenberg Apr 23, 2023
4b1ad15
feat: allow prototyped targets and fix targetting ids
dstallenberg May 1, 2023
de2acd3
fix: exports.x targetting
dstallenberg May 1, 2023
b52a6e6
fix: some bugs
dstallenberg May 1, 2023
55c2f43
fix: final updates
dstallenberg May 2, 2023
50bc3ca
chore: update package versions to latest beta releases
dstallenberg May 23, 2023
a23fe4c
fix: dependency path in test case
dstallenberg May 23, 2023
84a96db
test: fix failing test cases
dstallenberg May 23, 2023
e18c5f7
test: fix failing tests
dstallenberg May 25, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion .eslintignore
Expand Up @@ -11,9 +11,13 @@ syntest/
LICENSE*
Dockerfile
NOTICE
commitlint.config.js
link.sh


# The instrumentation files are copied from istanbul (and modified).
# In the future in a big refactor the instrumentation should be redone such that these files dont have to be ignored anymore.
**/instrumentation/Instrumenter.ts
**/instrumentation/VisitState.ts
**/instrumentation/Visitor.ts
**/instrumentation/Visitor.ts
**/instrumentation/source-coverage.ts
66 changes: 56 additions & 10 deletions .eslintrc.json
@@ -1,27 +1,73 @@
{
"env": {
"es6": true,
"es2021": true,
"mocha": true,
"node": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"prettier"
// "plugin:@typescript-eslint/recommended-requiring-type-checking", // TODO later too much work currently
"plugin:unicorn/recommended",
// "plugin:import/recommended", // TODO gives weird errors
"plugin:import/typescript",
"plugin:promise/recommended",
"prettier"//,
// "plugin:sonarjs/recommended" // TODO later too much work currently
],
"parser": "@typescript-eslint/parser",
// "parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module"
"ecmaVersion": 2021,
"sourceType": "module"//,
// "project": "./tsconfig.json",
// "tsconfigRootDir": "."
},
"plugins": ["@typescript-eslint", "notice"],
"settings": {
"import/resolver": {
"typescript": true,
"node": true
}
},
"plugins": [
"@typescript-eslint",
"notice",
"unused-imports"
],
"rules": {
"no-fallthrough": "off",
"notice/notice":["error",
// "import/first": "error",
// "import/newline-after-import": "error",
// "import/no-duplicates": "error",
// "import/order": ["error",
// {
// "alphabetize": {
// "order": "asc",
// "caseInsensitive": true
// },
// "newlines-between": "always"
// }
// ],
// "sort-imports": ["error",
// {
// "ignoreDeclarationSort": true,
// "ignoreCase": true
// }
// ],
"notice/notice": [
"error",
{
"templateFile": "./LICENSE.header.ts",
"nonMatchingTolerance": 0.8
}
]
}
],
"unicorn/filename-case": "off",
// "no-unused-vars": "off",
// "@typescript-eslint/no-unused-vars": "off",
// "unused-imports/no-unused-imports": "error",
// "unused-imports/no-unused-vars": [
// "error",
// { "vars": "all", "varsIgnorePattern": "^_", "args": "after-used", "argsIgnorePattern": "^_" }
// ],
"no-fallthrough": "off",
"unicorn/expiring-todo-comments": "off"
}
}
7 changes: 4 additions & 3 deletions .github/workflows/main-test.yml
Expand Up @@ -61,10 +61,11 @@ jobs:
matrix:
# Collect coverage for all packages and plugins
package:
- libraries/ast-javascript
- libraries/cfg-javascript
- libraries/analysis-javascript
- libraries/ast-visitor-javascript
- libraries/instrumentation-javascript
- libraries/javascript
- libraries/search-javascript
- tools/javascript

steps:
# Download test results
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/pr-test.yml
Expand Up @@ -96,10 +96,11 @@ jobs:
matrix:
# Collect coverage for all packages and plugins
package:
- libraries/ast-javascript
- libraries/cfg-javascript
- libraries/analysis-javascript
- libraries/ast-visitor-javascript
- libraries/instrumentation-javascript
- libraries/javascript
- libraries/search-javascript
- tools/javascript

steps:
# Download test results
Expand Down
3 changes: 2 additions & 1 deletion .prettierignore
Expand Up @@ -4,4 +4,5 @@ node_modules/
.*
*.jpg
NOTICE
Dockerfile
Dockerfile
link.sh
69 changes: 32 additions & 37 deletions README.md
Expand Up @@ -16,67 +16,62 @@ The common core contains the common interfaces for the code control-flow represe

#### NPM

The simplest way to use syntest-javascript is by installing the [npm package](https://www.npmjs.com/package/syntest/javascript).
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).

```bash
$ npm install @syntest/cli
$ npm install @syntest/javascript
```

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`.

#### From source

The tool can be used by cloning the project, installing its dependencies, and compiling the TypeScript:

- Clone the projects
## Usage

```bash
$ git clone git@github.com:syntest-framework/syntest-javascript.git
```
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.

- Install dependencies
Next, you want to run the following command:

```bash
$ cd syntest-javascript; npm install
$ npx syntest init config --modules @syntest/javascript
```

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

```bash
$ cd syntest-javascript; npm run build
```

You can create a `.syntest.js` file to change the way the tool behaves.

Finally run the tool

```bash
cd <PATH_TO_SYNTEST_JAVASCRIPT>; npm run standalone
{
...,
"target-root-directory": "./express",
"include": [
"./express/lib/**/*.js"
],
"exclude": [],
"modules": [
"@syntest/javascript"
],
"preset": "DynaMOSA"
...
}
```

The results can be found in the `syntest` folder

## Usage
In the above example the most important configuration options are shown.

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.
- The preset value which decides the algorithms the tool will use.
- The loaded module "@syntest/javascript".
- The target root directory which is the source directory of all the files you want to target.
- The include array where you can specify which files to target.
- The exclude array where you can specify which files to exclude specifically

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

```bash
$ syntest-javascript --target-root-directory="<PATH_TO_YOUR_SOURCE_FOLDER>/src" --total-time=10
$ npx syntest javascript test
```

This will test all javascript code that is contained in the source folder. It will run for 10 seconds.

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:
If everything is correct the tool will now start.
The results can be found in the `syntest` folder

```js
module.exports = {
"population-size": 10,
"max-depth": 5,
...
}
```
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.

## Documentation

Expand Down
59 changes: 59 additions & 0 deletions libraries/analysis-javascript/index.ts
@@ -0,0 +1,59 @@
/*
* Copyright 2020-2023 Delft University of Technology and SynTest contributors
*
* This file is part of SynTest Framework - SynTest Javascript.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export * from "./lib/ast/AbstractSyntaxTreeFactory";
export * from "./lib/ast/defaultBabelConfig";

export * from "./lib/cfg/ControlFlowGraphFactory";
export * from "./lib/cfg/ControlFlowGraphVisitor";

export * from "./lib/dependency/DependencyFactory";
export * from "./lib/dependency/DependencyVisitor";

export * from "./lib/target/export/Export";
export * from "./lib/target/export/ExportDefaultDeclaration";
export * from "./lib/target/export/ExportFactory";
export * from "./lib/target/export/ExportNamedDeclaration";
export * from "./lib/target/export/ExportVisitor";
export * from "./lib/target/export/ExpressionStatement";

export * from "./lib/target/Target";
export * from "./lib/target/TargetFactory";
export * from "./lib/target/TargetVisitor";
export * from "./lib/target/VisibilityType";

export * from "./lib/type/discovery/element/Element";
export * from "./lib/type/discovery/element/ElementVisitor";

export * from "./lib/type/discovery/object/DiscoveredType";
export * from "./lib/type/discovery/object/ObjectVisitor";

export * from "./lib/type/discovery/relation/Relation";
export * from "./lib/type/discovery/relation/RelationVisitor";

export * from "./lib/type/discovery/TypeExtractor";

export * from "./lib/type/resolving/Type";
export * from "./lib/type/resolving/TypeEnum";
export * from "./lib/type/resolving/TypeModel";
export * from "./lib/type/resolving/TypeModelFactory";
export * from "./lib/type/resolving/InferenceTypeModelFactory";
export * from "./lib/type/resolving/RandomTypeModelFactory";

export * from "./lib/utils/fileSystem";

export * from "./lib/RootContext";