summaryrefslogtreecommitdiff
path: root/test
Commit message (Collapse)AuthorAgeFilesLines
* context: Cleanup completed trampoline in context, as this is what they belong toMarco Trevisan (Treviño)2021-08-011-0/+1
| | | | | | We're currently keeping a list of trampolines in a static vector, this is acceptable (at least for a single-context scenario), but trampolines are bound to a specific context so better to move the handling in the context.
* GjsMaybeOwned: Remove notifier support and move it into GjsPrivateContextMarco Trevisan (Treviño)2021-08-011-4/+7
| | | | | | | | | | | | | | GjsMaybeOwned had a notification support that was used only by Closures (other than tests), this was causing adding an extra pointer to all the types using it (including Object) that was mostly unused. So, move this into private context, re-implementing it using our own notifier (instead of relying on GObject's that needs a specific order) and use it in closures. Also add an hook to handle gc events on private context that will be in later changes to cleanup more things, but for now is used to shrink the closures vector once we've done.
* jsapi-util-args: Add 'S' conversion specifierPhilip Chimento2021-07-021-21/+35
| | | | | | | | The 'S' specifier also expects a string argument, or additionally null if it is given as '?S'. Unlike 's' and 'F', it does not convert the string value at all, and instead puts it into a JS::MutableHandleString. This will be used in the Encoding specification.
* jsapi-util-args: Fix assert_match() in testsPhilip Chimento2021-07-021-9/+10
| | | | | | | | | | Apparently I never checked what happened when this assertion failed. Since it is only used directly in run_code_expect_exception(), the string and pattern are generated dynamically, so the error message would be something like '("message" matches "pattern")', totally unhelpful. Use g_assertion_message_cmpstr() with a made-up comparison operator, to give a more helpful message.
* CI: Add autoconf213 to dependencies in DockerfilePhilip Chimento2021-06-082-3/+3
| | | | | | | | | Fedora removed this from their build dependencies of mozjs78, but they had to add a big patch which we don't want to carry in ptomato/mozjs. So add autoconf213 to the list of dependencies to install manually. See commit: https://src.fedoraproject.org/rpms/mozjs78/c/0be21c3fd170b1e5e5920c4a59d6c7d6c6b9c7f7?branch=f33
* jsapi-util-string: Handle BigInt in gjs_debug_value()Philip Chimento2021-06-081-0/+36
| | | | | We print out the value % INT64_MAX in this debug function because printing out the full value requires a JSContext and may be fallible.
* object: Make ensure_toggle_reference to follow the JS API so we can throwMarco Trevisan (Treviño)2021-05-181-1/+2
|
* gjs-test-utils: Be more liberal in comparing values of different typesMarco Trevisan (Treviño)2021-05-181-2/+17
| | | | | | We can safely compare integers of different sizes, assuming they're both signed (or unsigned). So assert this instead of requiring two arguments of the very same type.
* mem-private: Do not use volatile for atomic valuesMarco Trevisan (Treviño)2021-05-171-1/+1
| | | | Following what GLib did as well everywhere.
* test: Move gjs-test code into Gjs::Test namespaceMarco Trevisan (Treviño)2021-05-181-0/+7
| | | | Will help avoiding clashes in unity builds
* tests: Add unit tests for ToggleQueue and ObjectInstance usage of itMarco Trevisan (Treviño)2021-05-184-1/+699
| | | | | | Instead of relying only on (at times unpredictible) JS tests for toggle queue handling and Objects memory management, add unit tests in which we manually handle an ObjectInstance and we simulate toggle events on it.
* tests: Move internal API tests into a different test binaryMarco Trevisan (Treviño)2021-05-183-10/+54
|
* test: Move assert_equal definition into Gjs::Test and common headerMarco Trevisan (Treviño)2021-05-172-17/+36
|
* test: Add a CI job that ensures that PCH file is populated with all headersMarco Trevisan (Treviño)2021-05-161-0/+187
| | | | | | | | ...And the other way around, so that we won't include more than needed both in code and pch headers As per this we need to install actual bash and grep on alpine as this script needs those features (which are not provided by buysbox).
* jsapi-util-string: Print quotes around strings in gjs_debug_value()Philip Chimento2021-04-201-0/+36
| | | | | | | | | In order to go along with the other source-like representations in gjs_debug_value(), such as Symbol("foo") and 42n, print quotes around strings. However, when printing strings as a property key in gjs_debug_id(), don't print quotes.
* Upgrades codespell to 2.0.0 in CI and adds suggestions by codespell packageKajal Sah2021-04-051-1/+1
|
* Refactor ARGV handling and add system.programArgs.ewlsh/refactor-argvEvan Welsh2021-02-111-0/+24
| | | | | (Changes from Philip folded in: use native function with reserved slot to store built argv array)
* Add dynamic import support to scriptsEvan Welsh2021-02-081-0/+81
| | | | | To allow import() from scripts we must set script privates with an object similar to the ModulePrivate class.
* esm: Enable static module imports.Evan Welsh2021-02-068-0/+204
| | | | | | (Changes from Philip folded in: tests, moving file operations into internal.cpp, store module loader in global, some renames, some added comments)
* js: Use strings and stringstreams instead of GStringPhilip Chimento2021-01-021-16/+6
| | | | | | | | | | | | | | | | | std::ostringstream is the C++ standard library version of GString. If we are not doing any formatting but only appending other strings, then we can even just use std::string and the + operator. This allows using RAII so we can get rid of a goto, and just generally be more memory-safe. We continue using GString in gjs_hyphen_from_camel() for performance reasons, because we would like a modifiable C buffer that we can pass to canonicalize_key(), and the only way to get a modifiable buffer out of std::string would be to copy it. Note: stream.str() _creates_ a std::string object, and copies the string data. string.c_str() returns a const char* _without_ copying.
* CI: Fix getting the upstream basePhilip Chimento2021-01-021-4/+11
| | | | | | | | | | | | | | Use git-merge-base to calculate the newest common ancestor, which should be more reliable. Also increase the horizon to 28 days since the newest common ancestor of this very merge request is more than 14 days old. Check that any commits were fetched (if not, "the remote end hung up unexpectedly") and fetch the last 30 commits instead if it didn't work. (Code review suggestion from Evan) As well, it seems that this feature does not always work quite correctly, so it would be good to have some debug output.
* test: Silence self-assignment clang warning in a more idiomatic wayPhilip Chimento2020-12-031-8/+1
| | | | | Clang also understands the idiom `a = *&a` to silence warnings about self- assignment if it is done intentionally.
* test: Use g_assert_{true,false} in unit tests instead of g_assertPhilip Chimento2020-12-031-44/+44
| | | | | g_assert can be compiled out with G_DISABLE_ASSERT, so it should not be used in unit tests.
* CI: Remove JHBuild line from CI scriptPhilip Chimento2020-12-031-1/+0
| | | | JHBuild is no longer used.
* CI: Install sysprof from package instead of building itPhilip Chimento2020-12-031-16/+3
| | | | | Now that we've upgraded to Fedora 33, we can avoid building sysprof ourselves and just use the distro package.
* Revert "Merge branch 'ewlsh/fix-ci' into 'master'"revert-6ce45bb3Evan Welsh2020-12-031-1/+1
| | | This reverts merge request !544
* ci: When finding common ancestors use source branch or commit branch.ewlsh/fix-ciEvan Welsh2020-12-021-1/+1
|
* CI: Compare cpplint and IWYU against the pull request's base branchPhilip Chimento2020-11-301-34/+61
| | | | | | | | | | Instead of always comparing against GNOME/gjs/master, try to find the place where the current branch was branched off of the upstream repository using an adaptation of the script that GLib uses. The main adaptation compared to GLib is that we are running on a lightweight image with sh and busybox, so we don't have fancy things like process redirection and diff formatting options.
* CI: Limit bandwidth usage for git clones during CIPhilip Chimento2020-11-303-4/+4
| | | | | | | | Clone everything at depth 1, omitting tags, and fetching a specific branch only. Thanks to: https://tecnocode.co.uk/2020/07/09/easily-speed-up-ci-by-reducing-download-size/
* CI: Make necessary changes to includes for IWYU 0.15Philip Chimento2020-11-301-0/+1
| | | | | | | IWYU 0.15 improves the accuracy of detecting missing includes, and also removes a few false positives but also adds new false positives. Since we are now running 0.15 in CI, we must adapt the postprocessing script, and make the necessary changes to the source files.
* test: Avoid including stddef.h for NULLPhilip Chimento2020-11-301-1/+1
| | | | Replace with nullptr which is a keyword.
* CI: Remove false positive includesPhilip Chimento2020-11-301-1/+0
| | | | | There were a few instances of this false positive already in the code base so remove those includes and add the files to the false positive list.
* maint: Add copyright notices based on major file contributorsPhilip Chimento2020-11-3010-0/+10
| | | | | | | | | | | | Based on looking at the git logs, add copyright notices to files which were missing them, assuming the copyright belongs to people who made major contributions to each file. Some assumptions were made as to who to assign the copyright to, such as, what copyright assignment did the contributor make in other files added in the same commit? What email address did they use to make the commit? What copyright assignment did they make in other commits using the same email address?
* CI: Upgrade mozjs78 images to Fedora 33Philip Chimento2020-11-232-12/+13
| | | | | | Allows us to move back to the distro's latest version of Meson, which no longer has the bug that considers skipped tests as failed. Also upgrades IWYU to 0.15, the version that goes along with Clang 11.
* CI: Stop building mozjs68 imagesPhilip Chimento2020-11-232-4/+4
| | | | | | | Now that we have switched to mozjs78 there's no longer a need to continue building new mozjs68 images. We can just use the one we currently have, until it's no longer needed. Switch the defaults in the Dockerfiles to build mozjs78 instead.
* Dockerfile: Allow to pass the mozjs base to use for build-depsMarco Trevisan (Treviño)2020-11-222-2/+4
| | | | And use them for mozjs78 builds, as build-deps may change
* CI: Use Fedora project registry images instead of DockerHubPhilip Chimento2020-11-222-4/+4
| | | | | Hopefully these are just drop-in replacements. We cannot rely on DockerHub anymore because they are rate-limiting pulls.
* CI: Replace cpplint image build and CI job with CI templatesPhilip Chimento2020-11-221-18/+0
| | | | | Since we are already building a light image with linters, add cpplint to it as well and remove the separate Dockerfile build.
* tests: Use GObject weak pointer to track test object refcountPhilip Chimento2020-11-221-204/+183
| | | | | | | The GObject.ref_count field is private, who knew! It is still accessible but apparently it messes up cppcheck, so we use GObject weak pointers instead to track the reference count of these objects, as demonstrated in https://stackoverflow.com/a/24459058/172999
* maint: Move expressions with side-effects out of assert statementsPhilip Chimento2020-11-221-2/+4
| | | | A newer version of cppcheck catches this.
* lint: Switch to eslint-plugin-jsdoc and remove lint-condo.Evan Welsh2020-11-201-0/+2
| | | | | | | | | | | ESLint has deprecated jsdoc and instead recommends eslint-plugin-jsdoc. lint-condo does not have eslint-plugin-jsdoc. We only use lint-condo for eslint currently and it is simpler to instead use yarn to install and manage eslint. Some module files had JSDoc comments which violated the jsdoc plugin's more stringent rules.
* jsapi-util: Add out operator to get the double pointerMarco Trevisan (Treviño)2020-10-271-0/+9
|
* jsapi-util: Make SFINAE on constructor to work with clang++Marco Trevisan (Treviño)2020-10-271-0/+7
| | | | | | | | | | | | | | | | | | As per C++ standard is perfectly legal for the compiler to check template definitions both during instantation (so looking at potential issues) and after their actual usage, so while g++ is more liberal on this and will not try to define functions which are disabled when allocating the template, clang++ will do it. So, in the case of using a void pointer to hold GjsAutoPointer it will complain when using void[] type. To avoid this, let's change the array constructor definition to use an implicit template value, while we still check it properly as part of the enable_if check, so that we'll eventually have the same result. Also fix other compilation issues due to clang being a bit more stricter.
* jsapi-util: Use constexpr based checks on GjsAutoPointer functionsMarco Trevisan (Treviño)2020-10-271-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | We had FIXME's about this for some time now, but we had a quite nice way to check whether we're handling nullptr functions at compile time, so that we can produce safe code with less dynamic checks: - Previously we were trying to use `if constexpr (ref_func != nullptr)` - The error we were getting was because we were trying to compare a template value (that will be evaluated at link time) with a null pointer (that yes, is a constant value). - However, C++ provides us since the long C++11 times a nice tool that allows to generate a type out from any constant value and that we can do use it to do constexpr checks. - Thus for each template function parameter we can just compute its integral constant type, and ensure that it's not matching null. Under the hood this will generate such types for examples: for g_object_ref: std::integral_constant<GObject* (*)(GObject*), g_object_ref>; for nullptr: std::integral_constant<GObject* (*)(GObject*), 0> And those types are indeed different. Added few tests, although to test invalid types we should add some no-compilation tests.
* jsapi-util: Add copy and equality operator to GjsAutoPointerMarco Trevisan (Treviño)2020-10-271-0/+87
| | | | | | | | | | | | Not being an unique_ptr anymore we've some more freedom (that will be way more when C++ will allow us to do more static checks), one of the good gain we've now, is that we can easily implement a copy and swap idiom to allow to pass the wrappers by value ensuring an internal copy. This will not work (unfortunately only with runtime checks! :-( ) if the wrapper doesn't provide a copy function, but this is still nice. Tests included.
* jsapi-util: Add copy function to GjsAutoStrv (and test it)Marco Trevisan (Treviño)2020-10-271-0/+25
|
* jsapi-util: Add back support for C++ objects and arrays to GjsAutoPointerMarco Trevisan (Treviño)2020-10-271-1/+56
| | | | | | | | As per moving away from std::unique_ptr we lost support for C++ native objects, even this may be optional (as we can just use stl containers for that), it's still nice to have. So add it back and include tests.
* jsapi-util: Rewrite GjsAutoPointer to only use template dataMarco Trevisan (Treviño)2020-10-274-0/+467
| | | | | | | | | | | | | | | | | | | | | We introduced GjsAutoPointer as part of commit dab3c7d06, to avoid duplication of the same code everywhere, and that served us well to create multiple smart pointer types, however since we were relying on std::unique_ptr, all the times we created a pointer with a custom destructor, we were allocating 8bits more, and this can be sensitive when used around in wrappers. However, since we are already constructing the auto-pointers passing all these information as template (generating some custom code, for sure), we can just rely on the template parameters also for the destructor, and so ensuring that the struct size always matches the wrapped pointer, removing all the overhead. This will allow to use GjsAutoPointer's everywhere without increasing the size of the wrapped objects. As per this being all new (even though the API is mainly inspired to unique_ptr), adding various unit tests to ensure we behave correctly.
* test: Increase the timeout for the API tests testMarco Trevisan (Treviño)2020-10-141-1/+1
|
* tests: Remove constexpr from get_random_numberPhilip Chimento2020-10-041-1/+2
| | | | | | GCC accepts this, but when compiling with Clang we get an error that the random number generator cannot be instantiated in a constant expression. That makes sense.