@qvac/translation-nmtcpp 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -437,6 +437,41 @@ The benchmarking covers:
437
437
 
438
438
  Results are updated regularly as new model versions are released.
439
439
 
440
+ ## Testing
441
+
442
+ This project includes comprehensive testing capabilities for both JavaScript and C++ components.
443
+
444
+ ### JavaScript Tests
445
+
446
+ ```bash
447
+ # Run all JavaScript tests
448
+ npm test # Unit + integration tests
449
+ npm run test:unit # Unit tests only
450
+ npm run test:integration # Integration tests only
451
+ ```
452
+
453
+ ### C++ Tests
454
+
455
+ The project includes C++ tests using Google Test framework.
456
+
457
+ #### npm Commands (Recommended - Cross-Platform)
458
+
459
+ ```bash
460
+ # Build and run C++ tests
461
+ npm run test:cpp:build # Build C++ test suite (auto-detects platform)
462
+ npm run test:cpp:run # Run all C++ unit tests
463
+ npm run test:cpp # Build and run in one command
464
+
465
+ # C++ Code Coverage
466
+ npm run coverage:cpp:build # Build with coverage instrumentation
467
+ npm run coverage:cpp:run # Run tests and collect coverage data
468
+ npm run coverage:cpp:report # Generate HTML coverage report
469
+ npm run coverage:cpp # Complete coverage workflow
470
+
471
+ # Combined Testing
472
+ npm run test:all # Run both JavaScript and C++ tests
473
+ ```
474
+
440
475
  ## Other Examples
441
476
 
442
477
  - [Filesystem Data Loader](examples/example.fs.js): Demonstrates using the library with the Filesystem Data Loader for Marian model inference.
package/marian.js CHANGED
@@ -23,10 +23,13 @@ class TranslationInterface {
23
23
  /**
24
24
  * Stops the current process execution,
25
25
  * frees memory allocated for configuration and weights,
26
- * and moves addon to the UNLOADED state.
26
+ * destroys the native instance, and moves addon to the UNLOADED state.
27
27
  */
28
28
  async unload () {
29
29
  binding.unload(this._handle)
30
+ // Automatically destroy the instance to free native resources
31
+ // This mirrors the pattern used in other QVAC addons
32
+ await this.destroy()
30
33
  }
31
34
 
32
35
  /**
@@ -168,6 +171,11 @@ class TranslationInterface {
168
171
  * Stops addon process and clears resources (including memory).
169
172
  */
170
173
  async destroy () {
174
+ // If already destroyed, do nothing
175
+ if (this._handle === null) {
176
+ return
177
+ }
178
+
171
179
  try {
172
180
  binding.destroyInstance(this._handle)
173
181
  this._handle = null
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qvac/translation-nmtcpp",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "translation addon for qvac",
5
5
  "addon": true,
6
6
  "engines": {
@@ -18,7 +18,17 @@
18
18
  "model:init": "qvac-dev model init",
19
19
  "model:new": "qvac-dev model new",
20
20
  "model:generate": "qvac-dev model generate",
21
- "test:dts": "tsc index.d.ts --noEmit"
21
+ "test:dts": "tsc index.d.ts --noEmit",
22
+ "test:cpp:build": "bare-make generate -D BUILD_TESTING=ON && bare-make build --target addon-test && bare-make install",
23
+ "test:cpp:run": "cd build/addon/tests/ && ./addon-test --gtest_output=xml:cpp-test-results.xml",
24
+ "test:cpp": "npm run test:cpp:build && npm run test:cpp:run",
25
+ "coverage:cpp:build": "bare-make generate -D BUILD_TESTING=ON -D ENABLE_COVERAGE=ON && bare-make build --target addon-test",
26
+ "coverage:cpp:run": "cd build/addon/tests/ && LLVM_PROFILE_FILE=default.profraw ./addon-test --gtest_output=xml:cpp-test-results.xml",
27
+ "coverage:cpp:summary" : "cd build/addon/tests && llvm-cov-19 report ./addon-test --instr-profile=coverage.profdata -ignore-filename-regex='(tests|build|node_modules|gtest|gmock|\\.vcpkg|/usr)/' > coverage-summary.txt",
28
+ "coverage:cpp:report": "cd build/addon/tests/ && ls -lha && llvm-profdata-19 merge -sparse default.profraw -o coverage.profdata && llvm-cov-19 show ./addon-test -instr-profile=coverage.profdata -format=html -output-dir=coverage-html -ignore-filename-regex='(tests|build|node_modules|gtest|gmock|\\.vcpkg|/usr)/' && llvm-cov-19 export ./addon-test -instr-profile=coverage.profdata -format=lcov -ignore-filename-regex='(tests|build|node_modules|gtest|gmock|\\.vcpkg|/usr)/' > lcov.info && npm run coverage:cpp:summary",
29
+ "coverage:cpp": "npm run coverage:cpp:build && npm run coverage:cpp:run && npm run coverage:cpp:report",
30
+ "test:all": "npm run test && npm run test:cpp"
31
+
22
32
  },
23
33
  "files": [
24
34
  "binding.js",
@@ -7,7 +7,7 @@
7
7
  ],
8
8
  "current_versions": [
9
9
  {
10
- "version": "0.1.1"
10
+ "version": "0.1.2"
11
11
  }
12
12
  ],
13
13
  "exported_symbols": [
@@ -420,6 +420,7 @@
420
420
  "__ZN4absl12lts_2024072213AbslParseFlagENS0_11string_viewEPNS0_11LogSeverityEPNSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEE",
421
421
  "__ZN4absl12lts_2024072214flags_internal7UnparseEd",
422
422
  "_ggml_rope_custom",
423
+ "__ZNK35qvac_lib_inference_addon_mlc_marian16TranslationModel9getConfigEv",
423
424
  "__ZN6google8protobuf2io16CodedInputStream7RefreshEv",
424
425
  "__ZN4absl12lts_2024072219str_format_internal13FlagsToStringENS1_5FlagsE",
425
426
  "__ZNK4absl12lts_2024072213time_internal4cctz9time_zone11descriptionEv",
@@ -498,6 +499,7 @@
498
499
  "_ggml_cont_1d",
499
500
  "__ZN4ggml3cpu13tensor_traitsD2Ev",
500
501
  "_ggml_compute_forward_repeat",
502
+ "__ZN35qvac_lib_inference_addon_mlc_marian16TranslationModel13unloadWeightsEv",
501
503
  "__ZNK13sentencepiece7unigram7Lattice7surfaceEi",
502
504
  "__Z21nmt_get_runtime_statsP11nmt_contextPdS1_Pi",
503
505
  "__ZN6google8protobuf8internal16ReadSizeFallbackEPKcj",
@@ -7,7 +7,7 @@
7
7
  ],
8
8
  "current_versions": [
9
9
  {
10
- "version": "0.1.1"
10
+ "version": "0.1.2"
11
11
  }
12
12
  ],
13
13
  "exported_symbols": [
@@ -533,6 +533,7 @@
533
533
  "__ZN4absl12lts_2024072213AbslParseFlagENS0_11string_viewEPNS0_11LogSeverityEPNSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEE",
534
534
  "__ZN4absl12lts_2024072214flags_internal7UnparseEd",
535
535
  "_ggml_rope_custom",
536
+ "__ZNK35qvac_lib_inference_addon_mlc_marian16TranslationModel9getConfigEv",
536
537
  "__ZN6google8protobuf2io16CodedInputStream7RefreshEv",
537
538
  "__ZN4absl12lts_2024072219str_format_internal13FlagsToStringENS1_5FlagsE",
538
539
  "__ZNK4absl12lts_2024072213time_internal4cctz9time_zone11descriptionEv",
@@ -611,6 +612,7 @@
611
612
  "_ggml_cont_1d",
612
613
  "__ZN4ggml3cpu13tensor_traitsD2Ev",
613
614
  "_ggml_compute_forward_repeat",
615
+ "__ZN35qvac_lib_inference_addon_mlc_marian16TranslationModel13unloadWeightsEv",
614
616
  "__ZNK13sentencepiece7unigram7Lattice7surfaceEi",
615
617
  "__Z21nmt_get_runtime_statsP11nmt_contextPdS1_Pi",
616
618
  "__ZN6google8protobuf8internal16ReadSizeFallbackEPKcj",
@@ -7,7 +7,7 @@
7
7
  ],
8
8
  "current_versions": [
9
9
  {
10
- "version": "0.1.1"
10
+ "version": "0.1.2"
11
11
  }
12
12
  ],
13
13
  "exported_symbols": [
@@ -418,6 +418,7 @@
418
418
  "__ZN4absl12lts_2024072213AbslParseFlagENS0_11string_viewEPNS0_11LogSeverityEPNSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEE",
419
419
  "__ZN4absl12lts_2024072214flags_internal7UnparseEd",
420
420
  "_ggml_rope_custom",
421
+ "__ZNK35qvac_lib_inference_addon_mlc_marian16TranslationModel9getConfigEv",
421
422
  "__ZN6google8protobuf2io16CodedInputStream7RefreshEv",
422
423
  "__ZN4absl12lts_2024072219str_format_internal13FlagsToStringENS1_5FlagsE",
423
424
  "__ZNK4absl12lts_2024072213time_internal4cctz9time_zone11descriptionEv",
@@ -496,6 +497,7 @@
496
497
  "_ggml_cont_1d",
497
498
  "__ZN4ggml3cpu13tensor_traitsD2Ev",
498
499
  "_ggml_compute_forward_repeat",
500
+ "__ZN35qvac_lib_inference_addon_mlc_marian16TranslationModel13unloadWeightsEv",
499
501
  "__ZNK13sentencepiece7unigram7Lattice7surfaceEi",
500
502
  "__Z21nmt_get_runtime_statsP11nmt_contextPdS1_Pi",
501
503
  "__ZN6google8protobuf8internal16ReadSizeFallbackEPKcj",
@@ -7,7 +7,7 @@
7
7
  ],
8
8
  "current_versions": [
9
9
  {
10
- "version": "0.1.1"
10
+ "version": "0.1.2"
11
11
  }
12
12
  ],
13
13
  "exported_symbols": [
@@ -418,6 +418,7 @@
418
418
  "__ZN4absl12lts_2024072213AbslParseFlagENS0_11string_viewEPNS0_11LogSeverityEPNSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEE",
419
419
  "__ZN4absl12lts_2024072214flags_internal7UnparseEd",
420
420
  "_ggml_rope_custom",
421
+ "__ZNK35qvac_lib_inference_addon_mlc_marian16TranslationModel9getConfigEv",
421
422
  "__ZN6google8protobuf2io16CodedInputStream7RefreshEv",
422
423
  "__ZN4absl12lts_2024072219str_format_internal13FlagsToStringENS1_5FlagsE",
423
424
  "__ZNK4absl12lts_2024072213time_internal4cctz9time_zone11descriptionEv",
@@ -496,6 +497,7 @@
496
497
  "_ggml_cont_1d",
497
498
  "__ZN4ggml3cpu13tensor_traitsD2Ev",
498
499
  "_ggml_compute_forward_repeat",
500
+ "__ZN35qvac_lib_inference_addon_mlc_marian16TranslationModel13unloadWeightsEv",
499
501
  "__ZNK13sentencepiece7unigram7Lattice7surfaceEi",
500
502
  "__Z21nmt_get_runtime_statsP11nmt_contextPdS1_Pi",
501
503
  "__ZN6google8protobuf8internal16ReadSizeFallbackEPKcj",
@@ -7,7 +7,7 @@
7
7
  ],
8
8
  "current_versions": [
9
9
  {
10
- "version": "0.1.1"
10
+ "version": "0.1.2"
11
11
  }
12
12
  ],
13
13
  "exported_symbols": [
@@ -539,6 +539,7 @@
539
539
  "__ZN4absl12lts_2024072213AbslParseFlagENS0_11string_viewEPNS0_11LogSeverityEPNSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEE",
540
540
  "__ZN4absl12lts_2024072214flags_internal7UnparseEd",
541
541
  "_ggml_rope_custom",
542
+ "__ZNK35qvac_lib_inference_addon_mlc_marian16TranslationModel9getConfigEv",
542
543
  "__ZN6google8protobuf2io16CodedInputStream7RefreshEv",
543
544
  "__ZN4absl12lts_2024072219str_format_internal13FlagsToStringENS1_5FlagsE",
544
545
  "__ZNK4absl12lts_2024072213time_internal4cctz9time_zone11descriptionEv",
@@ -617,6 +618,7 @@
617
618
  "_ggml_cont_1d",
618
619
  "__ZN4ggml3cpu13tensor_traitsD2Ev",
619
620
  "_ggml_compute_forward_repeat",
621
+ "__ZN35qvac_lib_inference_addon_mlc_marian16TranslationModel13unloadWeightsEv",
620
622
  "__ZNK13sentencepiece7unigram7Lattice7surfaceEi",
621
623
  "__Z21nmt_get_runtime_statsP11nmt_contextPdS1_Pi",
622
624
  "__ZN6google8protobuf8internal16ReadSizeFallbackEPKcj",