Patchwork D11003: windows: use cpu-intensive task instead of real time in test

login
register
mail settings
Submitter phabricator
Date July 7, 2021, 1:14 p.m.
Message ID <differential-rev-PHID-DREV-7nxxgavqdzugtp7g7pwa-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/49316/
State Superseded
Headers show

Comments

phabricator - July 7, 2021, 1:14 p.m.
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Windows profiling breaks when using real time instead of cpu, but we need the
  extension function to show up, so make it do something instead of waiting.
  I've also duplicated the test cases so that explicit real and CPU times are
  tested (on platforms other than Windows)

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D11003

AFFECTED FILES
  tests/test-profile.t

CHANGE DETAILS




To: Alphare, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/tests/test-profile.t b/tests/test-profile.t
--- a/tests/test-profile.t
+++ b/tests/test-profile.t
@@ -73,7 +73,9 @@ 
   > command = registrar.command(cmdtable)
   > @command(b'sleep', [], b'hg sleep')
   > def sleep_for_at_least_one_stat_cycle(ui, *args, **kwargs):
-  >     time.sleep(0.1)
+  >     t = time.time()  # don't use time.sleep because we need CPU time
+  >     while time.time() - t < 0.5:
+  >         pass
   > EOF
 
   $ cat >> $HGRCPATH << EOF
@@ -100,10 +102,19 @@ 
     %   cumulative      self          
   $ cat ../out | statprofran
 
-  $ hg --profile --config profiling.statformat=hotpath sleep 2>../out || cat ../out
+Windows real time tracking is broken, only use CPU
+
+#if no-windows
+  $ hg --profile --config profiling.time-track=real --config profiling.statformat=hotpath sleep 2>../out || cat ../out
   $ cat ../out | statprofran
-  $ grep sleepext_with_a_long_filename.py ../out
-  .* [0-9.]+%  [0-9.]+s  sleepext_with_a_long_filename.py:\s*sleep_for_at_least_one_stat_cycle, line 7:    time\.sleep.* (re)
+  $ grep sleepext_with_a_long_filename.py ../out | head -n 1
+  .* [0-9.]+%  [0-9.]+s  sleepext_with_a_long_filename.py:\s*sleep_for_at_least_one_stat_cycle, line \d+:\s+(while|pass).* (re)
+#endif
+
+  $ hg --profile --config profiling.time-track=cpu --config profiling.statformat=hotpath sleep 2>../out || cat ../out
+  $ cat ../out | statprofran
+  $ grep sleepext_with_a_long_filename.py ../out | head -n 1
+  .* [0-9.]+%  [0-9.]+s  sleepext_with_a_long_filename.py:\s*sleep_for_at_least_one_stat_cycle, line \d+:\s+(while|pass).* (re)
 
   $ hg --profile --config profiling.statformat=json sleep 2>../out || cat ../out
   $ cat ../out