mozext: unify into a single test and improve coverage (Bug 1569734) r=smacleod
authorConnor Sheehan <sheehan@mozilla.com>
Wed, 31 Jul 2019 21:08:13 +0000
changeset 7136 4851a84dfe4d05f73d8665b05e8cb902f6126455
parent 7135 c3b65e6e8bfbc8c35c2a2980a5f7b001a519c209
child 7137 28b74bc3450b49158fc18fbc3ef4790cd7387fa2
push id3551
push usercosheehan@mozilla.com
push dateWed, 31 Jul 2019 21:22:35 +0000
treeherderversion-control-tools@5e857d4f3091 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmacleod
bugs1569734
mozext: unify into a single test and improve coverage (Bug 1569734) r=smacleod The test coverage for `mozext` was quite lacking, and contributed to a lot of the bit rot in the last few months. In this commit I create a single unified test that covers most of the added template keywords, revset predicates and commands. Since we rely on the `pushlog` extension to enable several features, we pin the Mercurial used in `hg serve` to a known-compatible version. Changing this test and pinning the version of `hg` used to serve the pushlog allow us to remove the test from the flaky test list. Differential Revision: https://phabricator.services.mozilla.com/D39955
hgext/mozext/tests/test-backedoutby-mozext.t
hgext/mozext/tests/test-bugs-mozext.t
hgext/mozext/tests/test-mozext.t
hgext/mozext/tests/test-pushlog.t
testing/flaky-tests.txt
deleted file mode 100644
--- a/hgext/mozext/tests/test-backedoutby-mozext.t
+++ /dev/null
@@ -1,25 +0,0 @@
-  $ cat >> $HGRCPATH <<EOF
-  > [mozext]
-  > headless = True
-  > backoutsearchlimit = 100
-  > [extensions]
-  > mozext = $TESTDIR/hgext/mozext
-  > EOF
-
-{backedoutby} templates works
-
-  $ hg init backoutbytest
-  $ cd backoutbytest
-  $ touch foo
-  $ hg commit -A -m 'Foo'
-  adding foo
-  $ touch bar
-  $ hg commit -A -m 'Bar'
-  adding bar
-  $ hg backout -r tip -m "Backout 907f17e15674"
-  removing bar
-  changeset 2:47fdd3ef011e backs out changeset 1:907f17e15674
-  $ hg log -r -2 --template '{backedoutby}\n'
-  47fdd3ef011e5b86fe4ce90a88d362ac03361992
-  $ hg log -r 2 --template '{join(backsoutnodes, " ")}\n'
-  907f17e15674
deleted file mode 100644
--- a/hgext/mozext/tests/test-bugs-mozext.t
+++ /dev/null
@@ -1,23 +0,0 @@
-  $ cat >> $HGRCPATH <<EOF
-  > [mozext]
-  > headless = True
-  > [extensions]
-  > EOF
-  $ echo "mozext=$(echo $TESTDIR)/hgext/mozext" >> $HGRCPATH
-
-{bug} and {bugs} templates works
-
-  $ hg init bugtest
-  $ cd bugtest
-  $ touch foo
-  $ hg commit -A -m 'Bug 123456 - Test foo\nFixes bug 100245'
-  adding foo
-  $ hg log --template '{bug}\n'
-  123456
-  $ hg log --template '{join(bugs, " ")}\n'
-  123456 100245
-
-bug() revset works
-
-  $ hg log -r 'bug(123456)' --template '{rev}\n'
-  0
rename from hgext/mozext/tests/test-pushlog.t
rename to hgext/mozext/tests/test-mozext.t
--- a/hgext/mozext/tests/test-pushlog.t
+++ b/hgext/mozext/tests/test-mozext.t
@@ -6,74 +6,326 @@
   > mozext = $TESTDIR/hgext/mozext
   > localmozrepo = $TESTDIR/testing/local-mozilla-repos.py
   > 
   > [localmozrepo]
   > readuri = http://localhost:$HGPORT/
   > writeuri = ssh://user@dummy/$TESTTMP/
   > EOF
 
+  $ export PUSHLOGHG=$TESTDIR/venv/mercurials/5.0.1/bin/hg
+
   $ export USER=hguser
   $ hg init mozilla-central
   $ cd mozilla-central
   $ cat > .hg/hgrc << EOF
   > [extensions]
-  > pushlog = $TESTDIR/hgext/pushlog
+  > pushlog = $TESTDIR/hgext/pushlog/__init__.py
+  > pushlog-feed = $TESTDIR/hgext/pushlog/feed.py
+  > hgmo = $TESTDIR/hgext/hgmo
   > EOF
   $ cd ..
   $ cat > hgweb.conf << EOF
   > [paths]
   > / = $TESTTMP/*
+  > [web]
+  > push_ssl = False
+  > allow_push = *
   > EOF
-  $ hg serve -d -p $HGPORT --pid-file server.pid --web-conf hgweb.conf
+  $ $PUSHLOGHG serve -d -p $HGPORT --pid-file server.pid --web-conf hgweb.conf -E error.log
   $ cat server.pid >> $DAEMON_PIDS
 
+Set up a repository
+
   $ hg init client
   $ cd client
-  $ touch foo
-  $ hg -q commit -A -m initial
-  $ hg push ../mozilla-central
-  pushing to ../mozilla-central
+  $ touch baz
+  $ hg -q commit -A -m "initial DONTBUILD"
+  $ mkdir config
+  $ cat > config/milestone.txt << EOF
+  > # Some comments
+  > 14.0
+  > EOF
+  $ hg commit -A -m 'No bug: Milestone added'
+  adding config/milestone.txt
+  $ touch bar
+  $ hg commit -A -m 'Bar'
+  adding bar
+  $ hg backout -r tip
+  removing bar
+  changeset 3:ac2b8cb4ecf5 backs out changeset 2:98175e4fd343
+  $ echo foo > bar
+  $ hg commit -A -m 'Bug 1234567,9101112: print a commit on the command line r?glob,smacleod,hguser'
+  adding bar
+  $ hg bookmark -r tip central
+  $ hg push http://localhost:$HGPORT/mozilla-central -B central
+  pushing to http://localhost:$HGPORT/mozilla-central
   searching for changes
-  adding changesets
-  adding manifests
-  adding file changes
-  added 1 changesets with 1 changes to 1 files
-  recorded push in pushlog
+  remote: adding changesets
+  remote: adding manifests
+  remote: adding file changes
+  remote: added 5 changesets with 4 changes to 3 files
+  remote: recorded push in pushlog
+  exporting bookmark central
   $ cd ..
 
 Pull via http:// will fetch pushlog
 
   $ hg clone -U http://localhost:$HGPORT/mozilla-central clonehttp
   requesting all changes
   adding changesets
   adding manifests
   adding file changes
-  added 1 changesets with 1 changes to 1 files
+  added 5 changesets with 4 changes to 3 files
   added 1 pushes
-  new changesets 96ee1d7354c4 (?)
+  new changesets 28d014a3f251:d6d34e5ea05c
 
 Pull via ssh:// will not fetch pushlog
+Fails on Mercurials pre-4.8 due to Pushlog extension incompatible versions.
+Our hack to load pushlog with a compatible version only works for `hg serve`
+processes using HTTP
 
+#if hg48
   $ hg clone -U ssh://user@dummy/$TESTTMP/mozilla-central clonessh
   requesting all changes
   adding changesets
   adding manifests
   adding file changes
-  added 1 changesets with 1 changes to 1 files
+  added 5 changesets with 4 changes to 3 files
   cannot fetch pushlog when pulling via ssh://; you should be pulling via https://
-  new changesets 96ee1d7354c4 (?)
+  new changesets 28d014a3f251:d6d34e5ea05c
+#endif
 
-Test pushlog revsets and templates
+Show the dag
 
   $ cd clonehttp
+
+  $ hg log -G
+  o  changeset:   4:d6d34e5ea05c
+  |  bookmark:    central
+  |  tag:         tip
+  |  user:        test
+  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  summary:     Bug 1234567,9101112: print a commit on the command line r?glob,smacleod,hguser
+  |
+  o  changeset:   3:ac2b8cb4ecf5
+  |  user:        test
+  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  summary:     Backed out changeset 98175e4fd343
+  |
+  o  changeset:   2:98175e4fd343
+  |  user:        test
+  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  summary:     Bar
+  |
+  o  changeset:   1:a16e73662286
+  |  user:        test
+  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  summary:     No bug: Milestone added
+  |
+  o  changeset:   0:28d014a3f251
+     user:        test
+     date:        Thu Jan 01 00:00:00 1970 +0000
+     summary:     initial DONTBUILD
+  
+
   $ cat >> .hg/hgrc << EOF
+  > [ui]
+  > username = hguser
   > [extensions]
   > mozext = $TESTDIR/hgext/mozext
+  > [mozext]
+  > ircnick = hguser
   > EOF
-  $ hg log -T'{rev}\n'
-  0
+
+`me()` should match several values
+
+  $ hg log -r'me()' -T '{node}\n'  
+  d6d34e5ea05c48d5ae40f6f3d73beae8babe509c
+
+  $ hg --config ui.username= log -r'me()' -T '{node}\n'
+  abort: "[ui] username" must be set to use me()
+  [255]
+
+`dontbuild()` should match the commit that includes the magic words
+
+  $ hg log -r'dontbuild()' -T '{node}\n'
+  28d014a3f25108f2394610a033bf0bc8444c4f2f
+
+`bug(N)` returns changesets for the given bug
+
+  $ hg log -r'bug(1234567)' -T '{node}\n'
+  d6d34e5ea05c48d5ae40f6f3d73beae8babe509c
+
+`nobug()` returns changesets tagged as having no bug
+
+  $ hg log -r'nobug()' -T '{node}\n'
+  28d014a3f25108f2394610a033bf0bc8444c4f2f
+  a16e73662286ca2da14258dc8896eaafcf481c8e
+  98175e4fd343bc8e1e36d62982c9d5504c7f6419
+  ac2b8cb4ecf54cae779009fe21f5fab7fce71ce4
+
+`pushhead()` gets all heads for all trees, or a given tree
+
+  $ hg log -r'pushhead()' -T '{node}\n'
+  d6d34e5ea05c48d5ae40f6f3d73beae8babe509c
+
+  $ hg log -r'pushhead(central)' -T '{node}\n'
+  d6d34e5ea05c48d5ae40f6f3d73beae8babe509c
+
+`reviewer(name)` gets changes reviewed by "name"
+
+  $ hg log -r'reviewer(glob)' -T '{node}\n'
+  d6d34e5ea05c48d5ae40f6f3d73beae8babe509c
+
+`reviewed()` gets reviewed changesets
+
+  $ hg log -r'reviewed()' -T '{node}\n'
+  d6d34e5ea05c48d5ae40f6f3d73beae8babe509c
+
+`firstpushtree(central)` gets changes first pushed to the specified tree
+
+  $ hg log -r'firstpushtree(central)' -T '{node}\n'
+  28d014a3f25108f2394610a033bf0bc8444c4f2f
+  a16e73662286ca2da14258dc8896eaafcf481c8e
+  98175e4fd343bc8e1e36d62982c9d5504c7f6419
+  ac2b8cb4ecf54cae779009fe21f5fab7fce71ce4
+  d6d34e5ea05c48d5ae40f6f3d73beae8babe509c
+
+`firstpushdate()` should return no revisions for very recent date and all for very old date
+
   $ hg log -r'firstpushdate("> now")'
+  $ hg log -r'firstpushdate("-1")' -T'{desc|firstline}\n'
+  initial DONTBUILD
+  No bug: Milestone added
+  Bar
+  Backed out changeset 98175e4fd343
+  Bug 1234567,9101112: print a commit on the command line r?glob,smacleod,hguser
+
+`pushdate()` returns the same as above
+{firstpushdate} yields a date that can be parsed by a template filter
+
+
   $ hg log -r'pushdate("> now")'
-  $ hg log -r'firstpushdate("-1")' -T'{rev}\n'
-  0
   $ hg log -r'pushdate("-1")' -T'{rev} {firstpushdate|shortdate}\n'
   0 [0-9]{4}-[0-9]{2}-[0-9]{2} (re)
+  1 [0-9]{4}-[0-9]{2}-[0-9]{2} (re)
+  2 [0-9]{4}-[0-9]{2}-[0-9]{2} (re)
+  3 [0-9]{4}-[0-9]{2}-[0-9]{2} (re)
+  4 [0-9]{4}-[0-9]{2}-[0-9]{2} (re)
+
+{backedoutby} template works
+
+  $ hg log -r 98175e4fd343 --template '{backedoutby}\n'
+  ac2b8cb4ecf54cae779009fe21f5fab7fce71ce4
+
+{backsoutnodes} template works
+
+  $ hg log -r ac2b8cb4ecf5 --template '{join(backsoutnodes, " ")}\n'
+  98175e4fd343
+
+{bug} template returns first bug in commit message
+
+  $ hg log -r 4 --template '{bug}\n'
+  1234567
+
+{bugs} template returns all bugs in commit message
+
+  $ hg log -r 4 --template '{join(bugs, " ")}\n'
+  1234567 9101112
+
+{reviewer} template returns first reviewer in commit message
+
+  $ hg log -r 4 --template '{reviewer}\n'
+  glob
+
+{reviewers} template returns all reviewers in commit message
+
+  $ hg log -r 4 --template '{join(reviewers, " ")}\n'
+  glob smacleod hguser
+
+{firstrelease} template works
+
+  $ hg log -r 4 --template '{firstrelease}\n'
+  
+{firstbeta} template works
+
+  $ hg log -r 4 --template '{firstbeta}\n'
+  
+{firstnightly} template works
+
+  $ hg log -r 4 --template '{firstnightly}\n'
+  14.0
+
+{nightlydate} template works
+
+  $ hg log -r 4 --template '{nightlydate}\n'
+  [0-9]{4}-[0-9]{2}-[0-9]{2} (re)
+
+{firstpushuser} template works
+
+  $ hg log -r 4 --template '{firstpushuser}\n'
+  hguser
+
+{firstpushtree} template works
+
+  $ hg log -r 4 --template '{firstpushtree}\n'
+  central
+
+{firstpushtreeherder} template works
+
+  $ hg log -r 4 --template '{firstpushtreeherder}\n'
+  https://treeherder.mozilla.org/#/jobs?repo=mozilla-central&revision=d6d34e5ea05c48d5ae40f6f3d73beae8babe509c
+
+{pushdates} template works
+
+  $ hg log -r 4 --template '{pushdates % "{date|shortdate}"}\n'
+  1970-01-01
+
+{pushheaddates} template works
+
+  $ hg log -r 4 --template '{pushheaddates % "{date|shortdate}"}\n'
+  1970-01-01
+
+{trees} template works
+
+  $ hg log -r 4 --template '{trees}\n'
+  central
+
+{reltrees} template works
+
+  $ hg log -r 4 --template '{reltrees}\n'
+  central
+
+Confirm no errors in log
+
+  $ cat ../error.log
+
+
+TODOS
+=====
+
+- functionality that calls out to `mozautomation` for tree uris and other information
+- functionality that uses the local database (ie not the pushlog)
+
+`tree(tree)` gets changes in the specified tree
+This could probably be removed in favor of `::central` and `firefoxtree`
+
+$ hg log -r'tree(central)' -T '{node}\n'
+28d014a3f25108f2394610a033bf0bc8444c4f2f
+a16e73662286ca2da14258dc8896eaafcf481c8e
+98175e4fd343bc8e1e36d62982c9d5504c7f6419
+ac2b8cb4ecf54cae779009fe21f5fab7fce71ce4
+d6d34e5ea05c48d5ae40f6f3d73beae8babe509c
+
+`hg treestatus` show status of some trees
+convert this to a mach command instead?
+
+`hg treeherder` opens treeherder view for given revision
+on specified tree. Again, probably better as a mach command
+where we can support Git as well
+
+`hg changesetpushes` shows pushlog entries for a changeset
+Doesn't work for me
+
+`hg buginfo` shows information about patches with a given bug
+This can be achieved using the `bug()` revset predicate,
+might be worth removing
--- a/testing/flaky-tests.txt
+++ b/testing/flaky-tests.txt
@@ -1,15 +1,12 @@
 # List of "flaky" tests in version-control-tools
 # Everything in bzexport
 # Everything in bzpost
 
-# mozext test fails on pre-4.7 Mercurial due to pushlog dependency
-test-pushlog.t
-
 # robustcheckout test fails on post-4.7 Mercurial due to changes in hgweb
 test-server-failure.t
 
 # hghooks test fails when attempting to `hg strip`. Mostly unrelated to actual test
 test-prevent-webidl-changes.t
 
 # hgserver test shows bookmark as not-replicated, despite being replicated in later output
 test-bookmarks-replication.t