Skip to content

Commit

Permalink
chore(tests): skip coverage for results.sort
Browse files Browse the repository at this point in the history
We finally know why this is happening, and it's because
the array that it is sorting isn't deterministic. Explanation
is in the comments above the function, line is ignored, no
more random CI test failures.

PR-URL: #2523
Credit: @wraithgar
Close: #2523
Reviewed-by: @darcyclarke
  • Loading branch information
wraithgar authored and nlf committed Jan 28, 2021
1 parent d2f8af2 commit ba3aa4c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/help-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,15 @@ const searchFiles = async (args, data, files) => {

// sort results by number of results found, then by number of hits
// then by number of matching lines

// coverage is ignored here because the contents of results are
// nondeterministic due to either glob or readFiles or Object.entries
return results.sort((a, b) =>
a.found.length > b.found.length ? -1
: a.found.length < b.found.length ? 1
: a.totalHits > b.totalHits ? -1
: a.totalHits < b.totalHits ? 1
/* istanbul ignore next */
: a.lines.length > b.lines.length ? -1
: a.lines.length < b.lines.length ? 1
: 0).slice(0, 10)
Expand Down

0 comments on commit ba3aa4c

Please sign in to comment.