Skip to content

Commit

Permalink
added more information about testing on windows and linux
Browse files Browse the repository at this point in the history
  • Loading branch information
abner committed Apr 15, 2021
1 parent 47ff967 commit 3bdd3d1
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 12 deletions.
19 changes: 15 additions & 4 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,19 @@
"name": "flutter_js",
"request": "launch",
"type": "dart",
"args": ["--verbose"],
"args": [
"--verbose"
],
"program": "example/lib/main.dart"
},
{
"name": "example",
"cwd": "example",
"request": "launch",
"type": "dart",
"args": ["--verbose"]
"args": [
"--verbose"
]
},
{
"name": "packages",
Expand All @@ -28,8 +32,15 @@
"name": "test-with-flutterjs",
"type": "dart",
"program": "test/flutter_js_test.dart",
"env": {
"PATH": "${env:Path};${workspaceFolder}\\example\\build\\windows\\runner\\Debug"
"windows": {
"env": {
"PATH": "${env:Path};${workspaceFolder}\\example\\build\\windows\\runner\\Debug"
}
},
"linux": {
"env": {
"LIBQUICKJSC_TEST_PATH": "${workspaceFolder}/example/build/linux/debug/bundle/lib/libquickjs_c_bridge_plugin.so"
}
},
"request": "launch"
}
Expand Down
30 changes: 23 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -314,24 +314,40 @@ With the library being compiled and published to jitpack, applications using the

We can unit test evaluation of expressions on flutter_js using the desktop platforms (windows, linux and macos).

For `Windows` environment you need to build the executable first, and after you need to add the
path `build\windows\runner\Debug` (the absolute path) to your environment path.
For `Windows` and `Linux` you need to build your app Desktop executable first: `flutter build -d windows` or `flutter build -d linux`.

On Windows, after build your application for the first time, at least, add the path `build\windows\runner\Debug` (the absolute path) to your environment path.

In powershell, just run `$env:path += ";${pwd}\build\windows\runner\Debug"`. Now you can run the test in the command line session where you added the `\build\windows\runner\Debug` into the path.

To run the test integrated Visual Studio Code, you will need to setup a launcher to the .vscode/launch.json
so you can fill-in the build folder into the PATH:
For `Linux` you need to exports an environment variable called `LIBQUICKJSC_TEST_PATH` pointing to `build/linux/debug/bundle/lib/libquickjs_c_bridge_plugin.so`. eg: `export LIBQUICKJSC_TEST_PATH="$PWD/build/linux/debug/bundle/lib/libquickjs_c_bridge_plugin.so"`


To run the test integrated Visual Studio Code, you will need to setup a launcher to the `.vscode/launch.json` file,
so you can fill-in the build folder into the `PATH` on Windows and the `LIBQUICKJSC_TEST_PATH` for linux:

```json
{
"version": "0.2.0",
"configurations": [
{
"name": "test-with-flutterjs",
"type": "dart",
"program": "test/flutter_js_test.dart",
"env": {
"PATH": "${env:Path};${workspaceFolder}\\build\\windows\\runner\\Debug"
"windows": {
"env": {
"PATH": "${env:Path};${workspaceFolder}\\example\\build\\windows\\runner\\Debug"
}
},
"linux": {
"env": {
"LIBQUICKJSC_TEST_PATH": "${workspaceFolder}/example/build/linux/debug/bundle/lib/libquickjs_c_bridge_plugin.so"
}
},
"request": "launch"
}
]
}
```

> For MacOSx and Linux no extra step is needed.
> For running unit tests on MacOSx no extra step is needed.
2 changes: 1 addition & 1 deletion lib/quickjs/ffi.dart
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ final DynamicLibrary _qjsLib = Platform.environment['FLUTTER_TEST'] == 'true'
? DynamicLibrary.open('quickjs_c_bridge.dll')
: Platform.isMacOS
? DynamicLibrary.process()
: DynamicLibrary.open(Platform.environment['LIBQUICKJSC_PATH'] ??
: DynamicLibrary.open(Platform.environment['LIBQUICKJSC_TEST_PATH'] ??
'libquickjs_c_bridge_plugin.so'))
: (Platform.isWindows
? DynamicLibrary.open('quickjs_c_bridge.dll')
Expand Down

0 comments on commit 3bdd3d1

Please sign in to comment.