Commit Graph

77 Commits

Author SHA1 Message Date
Erez Geva 4b5c68d40f Add Javascript test for 'SWIG_FromUint8Array' and 'SWIG_ToUint8Array'
Signed-off-by: Erez Geva <ErezGeva2@gmail.com>
2026-08-01 10:40:22 +01:00
William S Fulton 261f9909d9 [JavaScript] Fix node engine builds when node-addon-api is missing
NAPI_DIR was empty when node-addon-api is not installed, so
CXXFLAGS="... -I$(NAPI_DIR)" ended in a bare -I. That swallowed the -c
option generated by node-gyp, so g++ linked instead of compiled and
failed with an undefined reference to main. This broke the node engine,
which does not use node-addon-api at all:

  cd Examples/javascript/class && make check ENGINE=node

Configure now substitutes the complete option as NAPI_INCLUDE, either
empty or a well formed -I, so the makefiles need no special casing.
Detection of distro supplied headers also moves out of the npm
conditional, enabling napi with the Debian/Ubuntu node-addon-api package
and no npm. The test-suite Makefile no longer hardcodes an include
directory derived from 'npm config get prefix', which is bogus without
npm and is already worked out by configure.

Assisted-by: Claude Code (Opus 5)
2026-07-31 02:14:40 +01:00
Erez Geva cd569d122a cdata.i changes and new test li_cdata_bytes
Fix guile cdata.

Add SWIG_BINSTR flag
- Add SWIG_FromBinCharPtrAndSize with the new flag
  To add languages that use Lib/cdata.i.
- python use binary string by using the new SWIG_BINSTR
  in SWIG_AsCharPtrAndSize and SWIG_FromBinCharPtrAndSize.

Languages that were changed to uses list
- Tcl use list of integers.
- scilab use list of uint8.
  And support passing list of numbers to C.

Add support to JavaScript
- use Uint8Array instead of strings.
- Add li_cdata_carrays. tests.
- Add li_cdata_bytes tests.
- Use Debian node-addon-api package location.
- napi folder location to Examples/test-suite/javascript/Makefile.in.
- Update documentation.

Update cdata.i documentation

This new cdata test focus on:
- Ensure we can receive proper data from C and pass proper data back to C.
- Use all possoble byte values , i.e. the full range of 0 to 255
  and ensure values 128 to 255 do not pass Unicode transformation (UTF-8/16).
- Ensure zero is a valid value and not a string null termination
  nor a modified UTF-8 which transform U+0000 to 0xC0 0x80.
- Check mutability of the cdata object.

Signed-off-by: Erez Geva <ErezGeva2@gmail.com>
2026-05-25 13:16:09 +01:00
William S Fulton 5275850028 Try replicate issue described in #3337 2026-02-20 19:35:40 +00:00
Olly Betts 0b4496a735 Fix testsuite SWIG warnings; enable SWIG -Werror
SWIG/mzscheme (aka racket) is excluded for now as it currently has a lot
of testsuite warnings and is slated for removal in 4.4.0 anyway.

Closes #3034
2024-10-22 10:30:52 +13:00
Olly Betts a06fc05303 [js] Clean up obsolete V8_VERSION machinery
This is no longer needed since we dropped support for the ancient
V8 versions which didn't provide version macros, but I missed
removing it in my previous cleanup in
48eba82ac8.
2024-09-18 18:28:59 +12:00
Vadim Zeitlin dbdbbe3fdf Allow suppressing progress messages when running test suite
Use $(ECHO_PROGRESS) instead of the hard-coded "echo" to allow setting
ECHO_PROGRESS=: on make command line to suppress the (many hundreds of)
messages given when running every unit test.

This makes it much easier to see any warnings given during the test
suite execution.
2024-06-25 07:54:57 +01:00
William S Fulton bd2dcf920c Correct attempts to not run tests in Javascript and Octave 2023-08-14 22:54:40 +01:00
Momtchil Momtchev ceed54758a Javascript Node-API support added
Closes #2545
2023-06-28 07:24:51 +01:00
Momtchil Momtchev d3e91b8273 another batch of run tests 2023-05-29 17:18:43 +02:00
Momtchil Momtchev 0d8ce6e031 add two Python tests 2023-05-29 12:42:59 +02:00
Momtchil Momtchev 1317583471 add two Python unit tests to JS 2023-05-26 16:54:41 +02:00
Olly Betts 7bb7295a33 [js] Improve default for JSENGINE
Previously the default was always "node", even if nodejs wasn't
detected by configure.  This leads to a confusing failure from
"make check" if you have another support JS engine installed
but not node.

Now the default it picked based on which engines configure
found.  If only one was detected, that should be used.  If
multiple are, you can override the default choice by specifying
e.g. ENGINE=jsc on the make command line.

Fixes #2453
2023-04-22 13:33:46 +12:00
Olly Betts b508598a42 [js] Turn on C++ output for node too
Nodejs is like V8 and needs C++ output enabled when wrapping C code.

The testsuite was masking this bug by using SWIG options
`-v8 -DBUILDING_NODE_EXTENSION=1` rather than `-node` when testing
with nodejs, while the javascript examples currently all seem to all get
processed with -c++.
2023-04-22 13:33:46 +12:00
William S Fulton e622a708d2 Fix Javascript node test-suite to use desired c++ standard
Passes the -std determined in configure.ac to node-gyp
2022-10-15 14:58:25 +01:00
William S Fulton 4a397869a2 Merge branch 'director-unwrap-result'
* director-unwrap-result:
  Unwrap director classes only when returning a pointer or reference to an object
2022-10-07 18:41:14 +01:00
Olly Betts 07f0b732ba Add machinery for C++14, C++17 and C++20 testing
Support running testcases conditional on the compiler supporting
a each language version, like we already handle C++11.

Currently no testcases are actually run in this way for these
newer language versions.
2022-07-26 15:28:51 +12:00
William S Fulton 5cc4591ae7 Consistent cpp11 testing in test-suite
Move HAVE_CXX11 into makefiles so that running test-suite
from top level directory or in the language's test-suite directory
is consistent. For example, running 'make check-java-test-suite'
behaves the same as 'cd Examples/test-suite/java && make check'.
2022-03-27 19:34:20 +01:00
Olly Betts deb7cbf741
Merge branch 'master' into director-unwrap-result 2022-03-01 11:34:59 +13:00
Seth R Johnson fc2b90acd1 Add a "diamond" pattern to multi-impmort test
This tests whether multiple modules can correctly import
the same common module.

```
a -> d
  -> b -> c -> d*
```
2022-02-12 19:40:03 -05:00
Olly Betts 31af3ce9bf Avoid -Wempty-body warnings from SWIG_contract_assert 2022-02-11 18:39:08 +13:00
Vadim Zeitlin 4b05d8d947 Don't run ccomplextest as part of JavaScript test suite
This test currently fails due to "I" being undefined, so disable it to
let the rest of the tests to pass and add it later when this can be
fixed.
2021-10-01 02:11:11 +02:00
Vadim Zeitlin 58a49bac66 Suppress more -Wignored-qualifiers in JavaScript tests
This is probably not the greatest idea, and it would be better to change
the generated code to avoid these tests instead, but it was already done
like this for several tests, so just add two more of them that generate
warnings such as

../../member_funcptr_galore_wrap.cxx: In function ‘SwigV8ReturnValue _wrap_MemberFuncPtrs_aaa6(const SwigV8Arguments&)’:
../../member_funcptr_galore_wrap.cxx:3495:90: error: type qualifiers ignored on cast result type [-Werror=ignored-qualifiers]
 3495 |   result = (int)((MemberFuncPtrs const *)arg1)->aaa6((short (Funcs::*const )(bool) const)arg2);
      |                                                                                          ^~~~

when using gcc 9.
2021-10-01 01:39:12 +02:00
William S Fulton 227614056b Convert javascript_arrays.i example into testcase 2021-03-06 10:55:47 +00:00
William S Fulton f318bb8286 Add missing clean targets
template_typedef_cplx2 files are generated by the template_typedef_import.multicpptest
but can also be cleaned by the template_typedef_cplx2.cpptest target.
2020-10-10 15:02:26 +01:00
William S Fulton fd592fdc3b Split C complex.h from C++ complex testing 2020-10-10 15:01:29 +01:00
William S Fulton 339377410b Put test in alphabetical order 2020-10-07 22:21:37 +01:00
Thomas Reitmayr 01277d700c Unwrap director classes only when returning a pointer or reference to an object
This involves properly counting the number of references and pointers in the return
type of a function and only generate unwrapping code if this number is 1.
For template instances some post-processing code is added to fix the 'decl' and
'type' attributes of functions if changed in an unfavorable way during template
expansion.
This commit fixes swig#1811.
2020-06-20 12:17:55 +02:00
Thomas Reitmayr c259702314 Perform proper spacing in director method declarations
If a director method returns a const pointer, eg. 'int *const', then in its
method declaration a space has to be inserted between 'const' and the
method name.
This fixes swig#1810.
2020-06-20 12:14:42 +02:00
William S Fulton 1f76cda125 Javascript test-suite Makefile parallel jobs
Suppress warning running test-suite and examples:
  make[1]: warning: jobserver unavailable: using -j1.  Add '+' to parent make rule.
Note that node-gyp uses make under the hood and clearing the MAKEFILE env is the
only way I could find to suppress this warning.
2018-05-17 08:15:48 +01:00
William S Fulton 7aa5f07dfd Fix 'make partialcheck-test-suite'
Python pep8 should not be run as part of partialcheck
Javascript should also only invoke SWIG during partialcheck
2016-03-18 18:56:55 +00:00
William S Fulton ca64b06229 Consistent quoting in Makefile 2015-08-21 22:48:34 +01:00
William S Fulton e00a8026a6 More remove SWIG_LIB variable 2015-08-21 22:48:34 +01:00
William S Fulton 1610ca86dd Fix javascript clean 2014-12-28 19:07:32 +00:00
William S Fulton 8b9d68582d Fix javascript clean
Regression introduced a couple of commits ago
2014-12-28 17:35:18 +00:00
William S Fulton 2b04d37b94 Tidy up Javascript build system 2014-12-28 16:13:22 +00:00
Richard b0afc7a9a5 Allow to specify V8 version, for example:
V8_VERSION=0x031511 ENGINE=v8 make check-javascript-test-suite
2014-08-28 19:46:49 -05:00
Karl Wette fca95febde Fully clean Javascript test-suite with jsc and v8 2014-05-29 02:29:27 +02:00
Oliver Buchtala 2471e4ad9f Javascript: Use RUNTOOL for running tests. 2014-05-19 12:11:15 +02:00
Oliver Buchtala a64549034c Javascript: generalise test-case 'typemap_variables' so that it can be used for Javascript V8.
The original version contains output typemaps that produced incompatible code.
Introduce a pre-processor macro that is set to a valid value for v8.
2014-05-19 00:58:32 +02:00
William S Fulton ac89f7f785 Javascript examples tidy up
- Remove empty files
- Improve clean
2014-05-18 00:59:47 +01:00
William S Fulton beccd3258f Update all languages to use SCRIPTDIR
R also to use SCRIPTPREFIX and SCRIPTSUFFIX
2014-05-15 23:11:07 +01:00
William S Fulton 2b5499a262 Slight simplification of test-suite build for new out-of-source changes
Provide default SRCDIR and SCRIPTDIR variables in common.mk and override
only where needed.
2014-05-15 23:11:07 +01:00
Karl Wette f574a34155 Allow examples and test-suite to be built out of source tree
- Examples/Makefile.in rules use SRCDIR as the relative source directory

- ./config.status replicates Examples/ source directory tree in build
  directory, and copies each Makefile to build directory, prefixed with
  a header which sets SRCDIR to source directory

- Examples/test-suite/.../Makefile.in set SRCDIR from Autoconf-set srcdir

- Examples/test-suite/errors/Makefile.in needs to filter out source
  directory from SWIG error messages

- Lua: embedded interpreters are passed location of run-time test

- Python: copy run-time scripts to build directory because of 2to3
  conversion; import_packages example copies __init__.py from source
  directory; test-suite sets SCRIPTDIR to location of run-time tests

- Javascript: binding.gyp renamed to binding.gyp.in so that $srcdir
  can be substituted with SRCDIR; removed './' from require() statements
  so that NODE_PATH can be used to point Node.js to build directory
2014-05-11 23:21:10 +02:00
Karl Wette 7cd9063b52 Remove execute permissions from various non-executable files
- source files and Makefiles need never be executable
- scripts are run directly by their interpreters in the
  test suites, so also do not need to be executable
2014-05-02 20:06:11 +02:00
William S Fulton 889c8e24c7 Javascript test-suite - warning suppression not needed 2014-04-24 22:49:48 +01:00
Oliver Buchtala 1d10a62192 Fix configuration for Javascript/node ctests. 2014-04-23 02:56:53 +02:00
Oliver Buchtala f3e3fce664 Fix configuration for ctest with Javascript/v8. 2014-04-23 02:25:07 +02:00
William S Fulton e730b16fac Revert "Javascript node test-suite makefile fixes for parallel make"
This reverts commit f105590c0a.
2014-04-21 11:23:14 +01:00
William S Fulton f105590c0a Javascript node test-suite makefile fixes for parallel make 2014-04-20 13:58:46 +01:00