-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Verify each target has the right number of tests #11998
Conversation
if not "*" in target and not self.excludes(("http://%s/" % target)): | ||
continue | ||
|
||
# '*.example.com' match 'www.example.com' but not 'secure.account.exmple.com' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Hainish does *.example.com
matches www.example.com
, secure.account.example.com
and example.com
? I am a bit confused seeing https://support.google.com/customsearch/answer/71826?hl=en and I not not sure how https-everywhere treat them. thanks in advance!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cschanaj the logic is here:
https-everywhere/chromium/rules.js
Lines 350 to 355 in 454fb4a
// now eat away from the left, with *, so that for x.y.z.google.com we | |
// check *.z.google.com and *.google.com (we did *.y.z.google.com above) | |
for (var i = 2; i <= segmented.length - 2; ++i) { | |
var t = "*." + segmented.slice(i,segmented.length).join("."); | |
results = results.concat(this.targets[t]); | |
} |
So to answer, for a.b.examble.com
, *.example.com
is a matching target.
Got it, I should have some time in the next few days to review this. |
@Hainish It seems that we treat implementation in
|
target |
regex interpretation |
---|---|
*.example.com |
^.+\.example\.com$ |
secure.*.example.com |
^secure\.[^\.]+\.example\.com$ |
www.example.* |
^www\.example\.[^\.]+$ |
I will have to make changes to this PR if this is true, please confirm. thanks!
@cschanaj I'm looking into this today! Sorry for the delay. |
continue | ||
|
||
# According to the logic in rules.js available at | ||
# EFForg/https-everywhere/blob/master/chromium/rules.js#L350-L355 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you include the commit hash in this URL? This way we can find the referenced code if it moves. You can get a permalink to lines in a specific version of the file by selecting the lines normally, then pressing "y".
pattern = pattern.replace('*', '.+') | ||
|
||
# however, `example.*` match `example.com` but not `example.co.uk` | ||
if pattern[len(pattern) - 1] == '*': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can get the last element like this: pattern[-1]
@cschanaj I'm not very familiar with running these tests. Would you mind providing a testcase this PR fixes? I would just run it by pointing the |
@cowlicks Sadly, Travis does not trigger $ export TEST=rules
$ ./test.sh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One bug, should be simple to fix. Everything else seems fine.
"""Verify that each rule and each exclusion has the right number of tests | ||
that applies to it. TODO: Also check that each target has the right | ||
"""Verify that each target, rule and exclusion has the right number of tests | ||
that applies to it. Also check that each target has the right | ||
number of tests. In particular left-wildcard targets should have at least | ||
three tests. Right-wildcard targets should have at least ten tests. | ||
|
||
Returns an array of strings reporting any coverage problems if they exist, | ||
or empty list if coverage is sufficient. | ||
""" | ||
problems = self._determineTestApplication() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Every "problem
" gets printed twice, they are created here in getCoverageProblems
. This happens because problems
is a reference to self.test_application_problems
through self._determineTestApplication
. Then again in getTargetValidityProblems
we do problems = self._determineTestApplication
, so the problems
from getCoverageProblems
also get reported through getTargetValidityProblems
.
I'm not sure why problems
is assigned like this. I'm guessing it is a mistake in either this function or getTargetValidityProblems
. Maybe @Hainish can chime in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cschanaj You can probably just change this to:
self._determineTestApplication()
problems = []
that is what other tests do
@cschanaj git can be tricky sometimes. I can fix this for you if you'd like. |
@cschanaj great work. Thank you. |
* Remove outdated TODO (fixed by #11998) * Remove html encoded characters * Surround XML tags and code with backticks * Wrap source to 80 characters * Add missing slash
blocked by #11187 which has been pending review for a long time... Also, merge #11942 before whitelisting
rules-test
.See https://gist.github.com/cschanaj/b3c80c935226c55e78013d81d618cd99
Related: #7272