From b4b424bf8ac26bb5fdb7fc4dd6c515cd9c6a6caa Mon Sep 17 00:00:00 2001 From: Laurent Cozic Date: Fri, 21 Feb 2020 12:15:06 +0000 Subject: [PATCH] Tools: Moved testing under "npm run test" and clean-up no longer used shell scripts --- .travis.yml | 2 +- BUILD.md | 2 -- CONTRIBUTING.md | 8 ++++---- CliClient/build-doc.sh | 2 +- CliClient/cli-integration.sh | 2 +- CliClient/fuzzing.sh | 2 +- CliClient/gulpfile.js | 22 ++++++++++++++++++++-- CliClient/package.json | 1 + CliClient/run_test.sh | 24 ------------------------ Tools/build-all.sh | 4 +++- Tools/release-cli.js | 4 ++-- readme/building_win32_tips.md | 5 +++++ 12 files changed, 39 insertions(+), 39 deletions(-) delete mode 100755 CliClient/run_test.sh diff --git a/.travis.yml b/.travis.yml index cebd10b7d3..ad542aaf36 100644 --- a/.travis.yml +++ b/.travis.yml @@ -66,7 +66,7 @@ script: # and that would break the desktop release. if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then cd CliClient - ./run_test.sh + npm run test testResult=$? if [ $testResult -ne 0 ]; then exit $testResult diff --git a/BUILD.md b/BUILD.md index 0d6c856cba..dbb2f3b854 100644 --- a/BUILD.md +++ b/BUILD.md @@ -75,8 +75,6 @@ If `yarn dist` fails, it may need administrative rights. If you get an `error MSB8020: The build tools for v140 cannot be found.` try to run with a different toolset version, eg `npm install --toolset=v141` (See [here](https://github.com/mapbox/node-sqlite3/issues/1124) for more info). -The [building\_win32\_tips on this page](./readme/building_win32_tips.md) might be helpful. - ## Other issues > The application window doesn't open or is white diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 57c1775a80..4bcbaf7564 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -61,19 +61,19 @@ npm install To run all the test units: ```sh -./run_test.sh +npm run test ``` To run just one particular file: ```sh -./run_test.sh markdownUtils # Don't add the .js extension +npm run test -- --filter=markdownUtils # Don't add the .js extension ``` -To filter tests: +To filter tests. For example, to run all the test units that contain "should handle conflict" in their description: ```sh -./run_test.sh "should handle conflict" # Will run all the test units that contain "should handle conflict" in their description +npm run test -- --filter="should handle conflict" ``` If you get the error `Cannot find module '/joplin/CliClient/node_modules/sqlite3/lib/binding/node-v79-darwin-x64/node_sqlite3.node'`, you may need to run `npm rebuild`. diff --git a/CliClient/build-doc.sh b/CliClient/build-doc.sh index fd3d21443c..434e3bd96a 100755 --- a/CliClient/build-doc.sh +++ b/CliClient/build-doc.sh @@ -1,3 +1,3 @@ #!/bin/bash set -e -./build.sh && NODE_PATH=build node build/build-doc.js \ No newline at end of file +npm run build && NODE_PATH=build node build/build-doc.js \ No newline at end of file diff --git a/CliClient/cli-integration.sh b/CliClient/cli-integration.sh index 6383a07485..d9b9c167e9 100755 --- a/CliClient/cli-integration.sh +++ b/CliClient/cli-integration.sh @@ -1,3 +1,3 @@ #!/bin/bash set -e -./build.sh && NODE_PATH="build/" node build/cli-integration-tests.js \ No newline at end of file +npm run build && NODE_PATH="build/" node build/cli-integration-tests.js \ No newline at end of file diff --git a/CliClient/fuzzing.sh b/CliClient/fuzzing.sh index a9c5aace8e..aea8ddbc27 100755 --- a/CliClient/fuzzing.sh +++ b/CliClient/fuzzing.sh @@ -1,3 +1,3 @@ #!/bin/bash set -e -./build.sh && NODE_PATH="build/" node build/fuzzing.js \ No newline at end of file +npm run build && NODE_PATH="build/" node build/fuzzing.js \ No newline at end of file diff --git a/CliClient/gulpfile.js b/CliClient/gulpfile.js index c731bbf287..8efa1e8386 100644 --- a/CliClient/gulpfile.js +++ b/CliClient/gulpfile.js @@ -5,10 +5,9 @@ const tasks = { copyLib: require('../Tools/gulp/tasks/copyLib'), }; -const buildDir = `${__dirname}/build`; - tasks.build = { fn: async () => { + const buildDir = `${__dirname}/build`; await utils.copyDir(`${__dirname}/app`, buildDir, { excluded: ['node_modules'], }); @@ -19,4 +18,23 @@ tasks.build = { }, }; +tasks.buildTests = { + fn: async () => { + const testBuildDir = `${__dirname}/tests-build`; + + await utils.copyDir(`${__dirname}/tests`, testBuildDir, { + excluded: [ + 'lib/', + 'locales/', + 'node_modules/', + ], + }); + + await utils.copyDir(`${__dirname}/../ReactNativeClient/lib`, `${testBuildDir}/lib`); + await utils.copyDir(`${__dirname}/../ReactNativeClient/locales`, `${testBuildDir}/locales`); + await fs.mkdirp(`${testBuildDir}/data`); + }, +}; + gulp.task('build', tasks.build.fn); +gulp.task('buildTests', tasks.buildTests.fn); diff --git a/CliClient/package.json b/CliClient/package.json index b6b6dcc619..d72f6481e0 100644 --- a/CliClient/package.json +++ b/CliClient/package.json @@ -4,6 +4,7 @@ "license": "MIT", "author": "Laurent Cozic", "scripts": { + "test": "gulp buildTests -L && jasmine --config=tests/support/jasmine.json", "postinstall": "patch-package && npm run build", "build": "gulp build", "start": "gulp build -L && node 'build/main.js' --profile ~/Temp/TestNotes2 --stack-trace-enabled --log-level debug --env dev" diff --git a/CliClient/run_test.sh b/CliClient/run_test.sh deleted file mode 100755 index d7b1dbbe6c..0000000000 --- a/CliClient/run_test.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash -START_DIR="$(pwd)" -ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -BUILD_DIR="$ROOT_DIR/tests-build" -FILTER="$1" - -rsync -a --delete --exclude "lib/" --exclude "locales/" --exclude "node_modules/" "$ROOT_DIR/tests/" "$BUILD_DIR/" -rsync -a --delete "$ROOT_DIR/../ReactNativeClient/lib/" "$BUILD_DIR/lib/" -rsync -a --delete "$ROOT_DIR/../ReactNativeClient/locales/" "$BUILD_DIR/locales/" -mkdir -p "$BUILD_DIR/data" - -function finish { - cd "$START_DIR" -} - -trap finish EXIT - -cd "$ROOT_DIR" - -if [[ $FILTER != "" ]]; then - npx jasmine --config=tests/support/jasmine.json --filter="$FILTER" -else - npx jasmine --config=tests/support/jasmine.json -fi diff --git a/Tools/build-all.sh b/Tools/build-all.sh index 1ed010320d..b610f8b9c0 100755 --- a/Tools/build-all.sh +++ b/Tools/build-all.sh @@ -7,7 +7,9 @@ echo "---------------------------------------------------" echo "Rebuild API doc..." echo "---------------------------------------------------" # TODO: When the apidoc command fails, it copy the failure in api.md, but shouldn't be doing that -"$ROOT_DIR/../CliClient/run.sh" apidoc > "$ROOT_DIR/../readme/api.md" +cd "$ROOT_DIR/../CliClient" +npm run start -- apidoc > "$ROOT_DIR/../readme/api.md" +cd "$ROOT_DIR" echo "---------------------------------------------------" echo "$ROOT_DIR/update-readme-download.js..." diff --git a/Tools/release-cli.js b/Tools/release-cli.js index 307a0d8aae..24e001be19 100644 --- a/Tools/release-cli.js +++ b/Tools/release-cli.js @@ -56,8 +56,9 @@ async function main() { console.info(`Building ${newVersion}...`); const newTag = `cli-${newVersion}`; + await execCommand('git pull'); await execCommand('touch app/main.js'); - await execCommand('bash build.sh'); + await execCommand('npm run build'); await execCommand('cp package.json build/'); await execCommand('cp ../README.md build/'); @@ -74,7 +75,6 @@ async function main() { const defaultEditor = await execCommand('echo $EDITOR'); const finalCmds = [ - 'git pull', 'git add -A', `git commit -m "CLI ${newVersion}"`, `git tag "cli-${newVersion}"`, diff --git a/readme/building_win32_tips.md b/readme/building_win32_tips.md index 1d252cc250..d9d639a354 100644 --- a/readme/building_win32_tips.md +++ b/readme/building_win32_tips.md @@ -1,3 +1,8 @@ +* * * + +**IMPORTANT: The build system has been changed since this document was written, thus it contains outdated information. It is kept for now as it may still contain some tips on how to get things working.** + +* * * ## Building Joplin on Windows