From 969c95f73f9bb255c79d53dd0a385caf32dcdb1c Mon Sep 17 00:00:00 2001 From: Yulong Wang <7679871+fs-eire@users.noreply.github.com> Date: Tue, 1 Aug 2023 11:17:39 -0700 Subject: [PATCH] [js/common] a few fixes/revises to onnxruntime-common (#16853) ### Description - enable unit test for js/common in CI - add debug config in js/.vscode/launch.json - enable source map for js/common/test for debugging purposes; add source map files to ignore list - ignore js/common/test folder for npm packaging --- js/.vscode/launch.json | 38 ++++++++++++++++++- js/common/.gitignore | 1 + js/common/.npmignore | 2 + js/common/package.json | 5 ++- js/common/test/tsconfig.json | 3 +- .../templates/linux-web-ci.yml | 4 ++ .../azure-pipelines/templates/win-web-ci.yml | 4 ++ 7 files changed, 52 insertions(+), 5 deletions(-) diff --git a/js/.vscode/launch.json b/js/.vscode/launch.json index 5c986ec6c9..4d9b6f3062 100644 --- a/js/.vscode/launch.json +++ b/js/.vscode/launch.json @@ -5,9 +5,43 @@ "version": "0.2.0", "configurations": [ { + "name": "[common] Launch Unit Tests", + "args": [ + "-u", + "bdd", + "--timeout", + "999999", + "--colors", + "${workspaceFolder}/common/test/**/*.js" + ], + "internalConsoleOptions": "openOnSessionStart", + "program": "${workspaceFolder}/node_modules/mocha/bin/_mocha", + "cwd": "${workspaceFolder}/common", + "request": "launch", + "skipFiles": [ + "/**" + ], + "type": "node", + "sourceMaps": true, + "preLaunchTask": "tsc: build - common/test/tsconfig.json" + }, + { + "name": "[web] Launch Test Runner", + "program": "${workspaceFolder}/web/script/test-runner-cli.js", + "request": "launch", + "skipFiles": [ + "/**" + ], + "type": "node", + "cwd": "${workspaceFolder}/web", + "args": [ + "suite1" + ] + }, + { + "name": "[web] Attach to Chrome", "type": "chrome", "request": "attach", - "name": "Attach to Chrome", "port": 9333, "webRoot": "${workspaceFolder}", "sourceMapPathOverrides": { @@ -18,7 +52,7 @@ "smartStep": true }, { - "name": "Remote Browser via Webkit Adaptor", + "name": "[web] Remote Browser via Webkit Adaptor", "type": "chrome", "request": "attach", "port": 9000, diff --git a/js/common/.gitignore b/js/common/.gitignore index 2ebebcad12..e5cc35f3cb 100644 --- a/js/common/.gitignore +++ b/js/common/.gitignore @@ -3,5 +3,6 @@ dist/ docs/ /test/**/*.js +/test/**/*.js.map tsconfig.tsbuildinfo diff --git a/js/common/.npmignore b/js/common/.npmignore index 37fefbcfcb..03cc37ddcd 100644 --- a/js/common/.npmignore +++ b/js/common/.npmignore @@ -6,4 +6,6 @@ typedoc.json tsconfig.json **/*.tsbuildinfo +/test/ + *.tgz diff --git a/js/common/package.json b/js/common/package.json index 77b8dd1729..331f17dbc4 100644 --- a/js/common/package.json +++ b/js/common/package.json @@ -13,8 +13,9 @@ "build:esm": "tsc", "build:bundles": "webpack", "build": "node ./build.js", - "prepare": "npm run build && tsc -p test", - "test": "mocha ./test/**/*.js" + "prepare": "npm run build", + "pretest": "tsc --build ./test", + "test": "mocha ./test/**/*.js --timeout 30000" }, "devDependencies": { "typedoc": "^0.23.22" diff --git a/js/common/test/tsconfig.json b/js/common/test/tsconfig.json index f3e7df044a..2e4927ac3b 100644 --- a/js/common/test/tsconfig.json +++ b/js/common/test/tsconfig.json @@ -2,6 +2,7 @@ "extends": "../../tsconfig.tools.json", "exclude": ["type-tests/**/*.ts"], "compilerOptions": { - "module": "ES2022" + "module": "ES2022", + "sourceMap": true } } diff --git a/tools/ci_build/github/azure-pipelines/templates/linux-web-ci.yml b/tools/ci_build/github/azure-pipelines/templates/linux-web-ci.yml index 3dc16d3332..66e4766e32 100644 --- a/tools/ci_build/github/azure-pipelines/templates/linux-web-ci.yml +++ b/tools/ci_build/github/azure-pipelines/templates/linux-web-ci.yml @@ -94,6 +94,10 @@ jobs: npm ci workingDirectory: '$(Build.SourcesDirectory)/js/common' displayName: 'npm ci /js/common/' + - script: | + npm test + workingDirectory: '$(Build.SourcesDirectory)/js/common' + displayName: 'run onnxruntime-common tests' - script: | npm ci workingDirectory: '$(Build.SourcesDirectory)/js/web' diff --git a/tools/ci_build/github/azure-pipelines/templates/win-web-ci.yml b/tools/ci_build/github/azure-pipelines/templates/win-web-ci.yml index b661ecd012..97af1386a5 100644 --- a/tools/ci_build/github/azure-pipelines/templates/win-web-ci.yml +++ b/tools/ci_build/github/azure-pipelines/templates/win-web-ci.yml @@ -102,6 +102,10 @@ jobs: npm ci workingDirectory: '$(Build.SourcesDirectory)\js\common' displayName: 'npm ci /js/common/' + - script: | + npm test + workingDirectory: '$(Build.SourcesDirectory)\js\common' + displayName: 'run onnxruntime-common tests' - script: | npm ci workingDirectory: '$(Build.SourcesDirectory)\js\web'