[gjs/322-treat-coverage-prefix-as-absolute-path] coverage: Treat coverage prefix as absolute path
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs/322-treat-coverage-prefix-as-absolute-path] coverage: Treat coverage prefix as absolute path
- Date: Mon, 10 Aug 2020 05:04:29 +0000 (UTC)
commit 2c32264382fb3d9065e1298d24d0f097fce664e5
Author: Philip Chimento <philip chimento gmail com>
Date: Sun Aug 9 22:04:20 2020 -0700
coverage: Treat coverage prefix as absolute path
Instead of comparing the coverage prefixes and filenames as strings,
make sure they are treated as absolute paths, if necessary resolved
against the current working directory.
This is a change in the behaviour of the coverage-prefix option, but I
believe it's overall beneficial. The only case that this change would
break, is using an absolute path as the coverage prefix, and a relative
path as the filename, or vice versa, in which case no coverage would
have been output anyway.
Closes: #322
gjs/coverage.cpp | 5 ++++-
installed-tests/scripts/testCommandLine.sh | 6 ++++++
2 files changed, 10 insertions(+), 1 deletion(-)
---
diff --git a/gjs/coverage.cpp b/gjs/coverage.cpp
index ab5b6ebf..b648ca22 100644
--- a/gjs/coverage.cpp
+++ b/gjs/coverage.cpp
@@ -175,9 +175,12 @@ static GParamSpec *properties[PROP_N] = { NULL, };
[[nodiscard]] static bool filename_has_coverage_prefixes(GjsCoverage* self,
const char* filename) {
auto priv = static_cast<GjsCoveragePrivate *>(gjs_coverage_get_instance_private(self));
+ GjsAutoChar workdir = g_get_current_dir();
+ GjsAutoChar abs_filename = g_canonicalize_filename(filename, workdir);
for (const char * const *prefix = priv->prefixes; *prefix; prefix++) {
- if (g_str_has_prefix(filename, *prefix))
+ GjsAutoChar abs_prefix = g_canonicalize_filename(*prefix, workdir);
+ if (g_str_has_prefix(abs_filename, abs_prefix))
return true;
}
return false;
diff --git a/installed-tests/scripts/testCommandLine.sh b/installed-tests/scripts/testCommandLine.sh
index 7cd71fc4..7769b3b7 100755
--- a/installed-tests/scripts/testCommandLine.sh
+++ b/installed-tests/scripts/testCommandLine.sh
@@ -247,6 +247,12 @@ else
skip "avoid crashing when GTK vfuncs are called on context destroy" "GTK disabled"
fi
+# https://gitlab.gnome.org/GNOME/gjs/-/issues/322
+$gjs --coverage-prefix=$(pwd) --coverage-output=$(pwd) awaitcatch.js
+grep -q TN: coverage.lcov
+report "coverage prefix is treated as an absolute path"
+rm -f coverage.lcov
+
rm -f exit.js help.js promise.js awaitcatch.js
echo "1..$total"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]