tests/test-logtoprocess.t
changeset 39925 dfca83594145
parent 34764 af43cb56af4e
child 39926 c4a3d3c67c4f
equal deleted inserted replaced
39924:7ea24d05d702 39925:dfca83594145
    25   $ cat >> $HGRCPATH << EOF
    25   $ cat >> $HGRCPATH << EOF
    26   > [extensions]
    26   > [extensions]
    27   > logtoprocess=
    27   > logtoprocess=
    28   > foocommand=$TESTTMP/foocommand.py
    28   > foocommand=$TESTTMP/foocommand.py
    29   > [logtoprocess]
    29   > [logtoprocess]
    30   > command=echo 'logtoprocess command output:';
    30   > command=(echo 'logtoprocess command output:';
    31   >     echo "\$EVENT";
    31   >     echo "\$EVENT";
    32   >     echo "\$MSG1";
    32   >     echo "\$MSG1";
    33   >     echo "\$MSG2"
    33   >     echo "\$MSG2") > $TESTTMP/command.log
    34   > commandfinish=echo 'logtoprocess commandfinish output:';
    34   > commandfinish=(echo 'logtoprocess commandfinish output:';
    35   >     echo "\$EVENT";
    35   >     echo "\$EVENT";
    36   >     echo "\$MSG1";
    36   >     echo "\$MSG1";
    37   >     echo "\$MSG2";
    37   >     echo "\$MSG2";
    38   >     echo "\$MSG3"
    38   >     echo "\$MSG3") > $TESTTMP/commandfinish.log
    39   > foo=echo 'logtoprocess foo output:';
    39   > foo=(echo 'logtoprocess foo output:';
    40   >     echo "\$EVENT";
    40   >     echo "\$EVENT";
    41   >     echo "\$MSG1";
    41   >     echo "\$MSG1";
    42   >     echo "\$OPT_BAR"
    42   >     echo "\$OPT_BAR") > $TESTTMP/foo.log
    43   > EOF
    43   > EOF
    44 
    44 
    45 Running a command triggers both a ui.log('command') and a
    45 Running a command triggers both a ui.log('command') and a
    46 ui.log('commandfinish') call. The foo command also uses ui.log.
    46 ui.log('commandfinish') call. The foo command also uses ui.log.
    47 
    47 
    48 Use sort to avoid ordering issues between the various processes we spawn:
    48 Use sort to avoid ordering issues between the various processes we spawn:
    49   $ hg foo | cat | sort
    49   $ hg foo
       
    50   $ sleep 0.2
       
    51   $ cat $TESTTMP/command.log | sort
    50   
    52   
       
    53   command
       
    54   foo
       
    55   foo
       
    56   logtoprocess command output:
       
    57 
       
    58 #if no-chg
       
    59   $ cat $TESTTMP/commandfinish.log | sort
    51   
    60   
    52   
       
    53    (chg !)
       
    54   0
    61   0
    55   a message: spam
       
    56   command
       
    57   command (chg !)
       
    58   commandfinish
    62   commandfinish
    59   foo
    63   foo
       
    64   foo exited 0 after * seconds (glob)
       
    65   logtoprocess commandfinish output:
       
    66   $ cat $TESTTMP/foo.log | sort
       
    67   
       
    68   a message: spam
    60   foo
    69   foo
    61   foo
       
    62   foo
       
    63   foo exited 0 after * seconds (glob)
       
    64   logtoprocess command output:
       
    65   logtoprocess command output: (chg !)
       
    66   logtoprocess commandfinish output:
       
    67   logtoprocess foo output:
    70   logtoprocess foo output:
    68   serve --cmdserver chgunix * (glob) (chg !)
       
    69   serve --cmdserver chgunix * (glob) (chg !)
       
    70   spam
    71   spam
       
    72 #endif
    71 
    73 
    72 Confirm that logging blocked time catches stdio properly:
    74 Confirm that logging blocked time catches stdio properly:
    73   $ cp $HGRCPATH.bak $HGRCPATH
    75   $ cp $HGRCPATH.bak $HGRCPATH
    74   $ cat >> $HGRCPATH << EOF
    76   $ cat >> $HGRCPATH << EOF
    75   > [extensions]
    77   > [extensions]
    76   > logtoprocess=
    78   > logtoprocess=
    77   > pager=
    79   > pager=
    78   > [logtoprocess]
    80   > [logtoprocess]
    79   > uiblocked=echo "\$EVENT stdio \$OPT_STDIO_BLOCKED ms command \$OPT_COMMAND_DURATION ms"
    81   > uiblocked=echo "\$EVENT stdio \$OPT_STDIO_BLOCKED ms command \$OPT_COMMAND_DURATION ms" > $TESTTMP/uiblocked.log
    80   > [ui]
    82   > [ui]
    81   > logblockedtimes=True
    83   > logblockedtimes=True
    82   > EOF
    84   > EOF
    83 
    85 
    84   $ hg log | cat
    86   $ hg log
       
    87   $ sleep 0.2
       
    88   $ cat $TESTTMP/uiblocked.log
    85   uiblocked stdio [0-9]+.[0-9]* ms command [0-9]+.[0-9]* ms (re)
    89   uiblocked stdio [0-9]+.[0-9]* ms command [0-9]+.[0-9]* ms (re)
       
    90 
       
    91 Try to confirm that pager wait on logtoprocess:
       
    92 
       
    93 Add a script that wait on a file to appears for 5 seconds, if it sees it touch
       
    94 another file or die after 5 seconds. If the scripts is awaited by hg, the
       
    95 script will die after the timeout before we could touch the file and the
       
    96 resulting file will not exists. If not, we will touch the file and see it.
       
    97 
       
    98   $ cat > $TESTTMP/wait-output.sh << EOF
       
    99   > #!/bin/sh
       
   100   > for i in \`$TESTDIR/seq.py 50\`; do
       
   101   >   if [ -f "$TESTTMP/wait-for-touched" ];
       
   102   >   then
       
   103   >     touch "$TESTTMP/touched";
       
   104   >     break;
       
   105   >   else
       
   106   >     sleep 0.1;
       
   107   >   fi
       
   108   > done
       
   109   > EOF
       
   110   $ chmod +x $TESTTMP/wait-output.sh
       
   111 
       
   112   $ cat >> $HGRCPATH << EOF
       
   113   > [extensions]
       
   114   > logtoprocess=
       
   115   > pager=
       
   116   > [logtoprocess]
       
   117   > commandfinish=$TESTTMP/wait-output.sh
       
   118   > EOF
       
   119   $ hg version -q --pager=always
       
   120   Mercurial Distributed SCM (version *) (glob)
       
   121   $ touch $TESTTMP/wait-for-touched
       
   122   $ sleep 0.2
       
   123   $ test -f $TESTTMP/touched && echo "SUCCESS Pager is not waiting on ltp" || echo "FAIL Pager is waiting on ltp"
       
   124   FAIL Pager is waiting on ltp