[gjs] coverage: Don't replace existing statistics with new ones
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs] coverage: Don't replace existing statistics with new ones
- Date: Mon, 3 Feb 2014 21:45:12 +0000 (UTC)
commit 8d8660d982be701f39898d5bac01f1bdd62a3b84
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Mon Feb 3 14:42:07 2014 -0500
coverage: Don't replace existing statistics with new ones
The existing code here relies on pendingFiles getting modified, which
is a bit tricky and won't work in our new prefix system. Instead, just
make ensureStatisticsFor return an existing object if it exists already.
modules/coverage.js | 11 +++++------
1 files changed, 5 insertions(+), 6 deletions(-)
---
diff --git a/modules/coverage.js b/modules/coverage.js
index 8ec96a2..845a9e5 100644
--- a/modules/coverage.js
+++ b/modules/coverage.js
@@ -652,15 +652,14 @@ function CoverageStatisticsContainer(files) {
let coveredFiles = {};
function ensureStatisticsFor(filename) {
- let statistics = _createStatisticsForFoundFilename(filename, pendingFiles);
- if (statistics)
- coveredFiles[filename] = statistics;
+ if (!coveredFiles[filename])
+ coveredFiles[filename] = _createStatisticsForFoundFilename(filename, pendingFiles);
+ return coveredFiles[filename];
}
this.fetchStatistics = function(filename) {
- ensureStatisticsFor(filename);
- let statistics = coveredFiles[filename];
- if (statistics === undefined)
+ let statistics = ensureStatisticsFor(filename);
+ if (statistics === null)
throw new Error('Not tracking statistics for ' + filename);
return statistics;
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]