summaryrefslogtreecommitdiff
path: root/test
Commit message (Collapse)AuthorAgeFilesLines
...
* 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.
* maint: Add dual MIT/LGPL license to all GJS files that didn't have onePhilip Chimento2020-10-0411-0/+17
| | | | | | This adds a SPDX-License-Identifier comment to all files that are part of GJS, part of its unit tests, or auxiliary tools. (Except for some files like the debugger scripts that don't support comments.)
* maint: Convert all existing license/copyright comments to SPDX formatPhilip Chimento2020-10-049-173/+21
| | | | | | | | The SPDX format is machine-readable, which should make it much easier to avoid mistakes with licensing and copyright using automated tools. This commit does not add any implicit information. It converts exactly what was already specified into SPDX format comments.
* gjs-tests: Add tests to verify rounded GArgument getterMarco Trevisan (Treviño)2020-09-191-0/+33
|
* gjs-tests: Add gjs_arg_* testsMarco Trevisan (Treviño)2020-09-191-1/+177
| | | | | | | | | | | | Ensure that gjs_arg_set, gjs_arg_get and gjs_arg_unset work as expected using random numbers that are generated per type and using some template functions to do smarter comparisions. Expose the random sed we used to generate the random numbers and generate the c++ one using a random number generated from g_test so that it will be consistent with `--seed` or in general with the GLib seed. Add support for a `--cpp-seed` option to be able to pass it one manually
* arg: Fix MIN/MAX safe big integer limitsMarco Trevisan (Treviño)2020-09-071-0/+32
| | | | | | | | | Current JS Number's MAX_SAFE_INTEGER value is set to 9007199254740991, however we set this value to 9007199254740992. Fix the number computation and add an unit test to ensure that the value we use is always matching JS definition (so that we are protected in the unlikely case that anything would change).
* coverage: Enable coverage before creating GjsContextPhilip Chimento2020-08-111-0/+1
| | | | | | | | Due to changes in SpiderMonkey 78, js::EnableCodeCoverage() must be called before using the code coverage APIs. Add a public GJS API that wraps this function, and gives a clear error message if it's not called. See: GNOME/gjs#329
* tests: Fix specifics in tests to match SpiderMonkey 78 outputPhilip Chimento2020-08-112-14/+15
| | | | | | | | | | | | | The LCOV output has changed slightly again in SpiderMonkey 78, so we must update our tests to match. There are trivial modifications such as changing the order that function records appear in, but it also seems that SpiderMonkey now reports more branches: for loop conditions and for default cases in switch statements. The gjs_parse_call_args() tests depend on the text of certain error messages, which were changed in SpiderMonkey 78. See: GNOME/gjs#329