summaryrefslogtreecommitdiff
path: root/test
Commit message (Collapse)AuthorAgeFilesLines
* 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
* engine: Update hook signatures.Evan Welsh2020-08-111-1/+1
| | | | | | | - Unhandled promises now have a mute flag. - Garbage collection now specifies the reason/source. See: GNOME/gjs#329
* js: Refactor Array-related JSAPI calls.Evan Welsh2020-08-111-2/+4
| | | | | | | | | | - <js/Array.h> and <js/ValueArray.h> are new headers. - Rename JS_NewArrayObject to JS::NewArrayObject. - Rename JS_GetArrayLength to JS::GetArrayLength. - Rename JS_IsArrayObject to JS::IsArrayObject. - Rename JS::AutoValueArray to JS::RootedValueArray. See: GNOME/gjs#329
* CI: Add mozjs78 imagesPhilip Chimento2020-08-042-4/+2
| | | | | | | The posix-nspr-emulation and unaligned-private-values options are gone, so we need to make those optional and blank them out for mozjs78. See: GNOME/gjs#329
* CI: Downgrade meson in debug image as wellPhilip Chimento2020-08-011-2/+2
| | | | See previous commit. Unreviewed, pushing to fix build.
* CI: Downgrade mesonPhilip Chimento2020-08-011-2/+2
| | | | | | | Meson 0.55.0's TAP support is broken. This is a workaround for https://github.com/mesonbuild/meson/issues/7515 Unreviewed, pushing to fix build.
* engine: Remove GJS_DISABLE_EXTRA_WARNINGSEvan Welsh2020-07-271-3/+3
| | | | | | | | | | SpiderMonkey 78 has removed this feature and recommends using linters. (For some bizarre reason, some of the output in the LCov coverage data is influenced by this flag, so we need to change some of the expected output.) See: GNOME/gjs#329
* CI: Build sysprof from source in debug imagePhilip Chimento2020-07-072-5/+18
| | | | | | We need sysprof-capture-4 which has not been released yet. So we need to build it ourselves. Build it only in the debug image, at least until it is packaged on Fedora.
* CI: Fix image buildsPhilip Chimento2020-07-051-1/+1
| | | | | Apparently llvm-config has been moved into a package that is no longer included in mozjs68's build dependencies.
* test: Mark that g_assertion_message() does not normally returnPhilip Chimento2020-07-045-0/+30
| | | | | | | | g_assertion_message() can return if nonfatal assertions are enabled, but for the purposes of static analysis, we want to consider it non- returning. See: GNOME/glib!1553
* CI: Add include-what-you-use to the debug CI imagePhilip Chimento2020-06-031-0/+77
| | | | | | This splits out a separate Dockerfile for the debug-enabled CI image, and builds include-what-you-use on it as well. We'll use this for some more automated code review.
* js: Fix header includes according to IWYUPhilip Chimento2020-05-203-5/+2
| | | | | | | This updates all the includes according to what IWYU suggests. In a few cases we move a typedef down in order to avoid IWYU wanting a forward declaration, or use a JS::Heap<T>{braced initializer} in order to avoid an implicit std::move.
* Merge branch '298-use-correct-asserts' into 'master'Philip Chimento2020-05-213-35/+36
|\ | | | | | | | | tests: Don't use g_assert and g_assert_not_reached in tests See merge request GNOME/gjs!430
| * tests: Don't use g_assert and g_assert_not_reached in testsPhilip Chimento2020-05-093-35/+36
| | | | | | | | | | | | | | These macros are no-ops if GLib is built with G_DISABLE_ASSERT, so they are not appropriate to use in tests. See: #298
* | CI: Correctly count errors in script testPhilip Chimento2020-05-161-1/+1
| | | | | | | | The previous code would produce a blank on 0 errors, not 0.
* | jsapi-util-args: Use args.requireAtLeast()Philip Chimento2020-05-161-3/+4
| | | | | | | | | | This method used to be broken in SpiderMonkey, but it's been fixed for a long time now.
* | CI: Build everything from a Dockerfile using buildahPhilip Chimento2020-05-113-113/+62
|/ | | | | Unfortunately, we can no longer use Docker because the runners are unprivileged.
* build: Only print full test logs on the build_recommended jobPhilip Chimento2020-04-261-2/+1
| | | | | | Most of the time we don't need these logs. Having them become too long seems to crash the CI job since a few days ago, unfortunately. So enable them only on one job, and make sure it is not the most verbose job.
* build: Remove last traces of AutotoolsPhilip Chimento2020-03-031-9/+0
| | | | These are some leftovers from Autotools' test harness.
* tests: Avoid filename conflict when tests run in parallelPhilip Chimento2020-02-231-0/+5
| | | | | | | | It seems that it's possible for the profiler start/stop test to have run during the script test that verifies that the profiler doesn't write a file, which causes it to fail because they both use the default profiler file name. Give the start/stop test a different file name and delete it afterwards.