diff options
-rw-r--r-- | coverage/cmdline.py | 3 | ||||
-rw-r--r-- | coverage/html.py | 1 | ||||
-rw-r--r-- | coverage/sqldata.py | 33 |
3 files changed, 24 insertions, 13 deletions
diff --git a/coverage/cmdline.py b/coverage/cmdline.py index 1c31b1e7..a6a72c32 100644 --- a/coverage/cmdline.py +++ b/coverage/cmdline.py @@ -346,7 +346,8 @@ CMDS = { Opts.omit, Opts.title, Opts.skip_covered, - Opts.show_contexts + Opts.show_contexts, + Opts.contexts, ] + GLOBAL_ARGS, usage="[options] [modules]", description=( diff --git a/coverage/html.py b/coverage/html.py index f7dbeba4..61edcb5d 100644 --- a/coverage/html.py +++ b/coverage/html.py @@ -124,6 +124,7 @@ class HtmlReporter(Reporter): """ assert self.config.html_dir, "must give a directory for html reporting" + self.coverage.get_data().set_query_contexts(self.config.query_contexts) # Read the status data. self.status.read(self.config.html_dir) diff --git a/coverage/sqldata.py b/coverage/sqldata.py index fe32dcdc..2feca6e0 100644 --- a/coverage/sqldata.py +++ b/coverage/sqldata.py @@ -627,23 +627,32 @@ class CoverageSqliteData(SimpleReprMixin): "where arc.file_id = ? and arc.context_id = context.id" ) data = [file_id] + context_ids = self._get_query_context_ids() + if context_ids is not None: + ids_array = ', '.join('?'*len(context_ids)) + query += " and arc.context_id in (" + ids_array + ")" + data += context_ids for fromno, tono, context in con.execute(query, data): if context not in lineno_contexts_map[fromno]: lineno_contexts_map[fromno].append(context) if context not in lineno_contexts_map[tono]: lineno_contexts_map[tono].append(context) - return lineno_contexts_map - - query = ( - "select line.lineno, context.context " - "from line, context " - "where line.file_id = ? and line.context_id = context.id" - ) - data = [file_id] - for lineno, context in con.execute(query, data): - if context not in lineno_contexts_map[lineno]: - lineno_contexts_map[lineno].append(context) - return lineno_contexts_map + else: + query = ( + "select line.lineno, context.context " + "from line, context " + "where line.file_id = ? and line.context_id = context.id" + ) + data = [file_id] + context_ids = self._get_query_context_ids() + if context_ids is not None: + ids_array = ', '.join('?'*len(context_ids)) + query += " and line.context_id in (" + ids_array + ")" + data += context_ids + for lineno, context in con.execute(query, data): + if context not in lineno_contexts_map[lineno]: + lineno_contexts_map[lineno].append(context) + return lineno_contexts_map def run_infos(self): return [] # TODO |