tests/test-server-view.t
author Augie Fackler <augie@google.com>
Mon, 08 Jul 2019 13:12:20 -0400
branchstable
changeset 42562 97ada9b8d51b
parent 42106 bcf59ddc6173
child 42231 d345627d104b
permissions -rw-r--r--
posix: always seek to EOF when opening a file in append mode Python 3 already does this, so skip it there. Consider the program: #include <stdio.h> int main() { FILE *f = fopen("narf", "w"); fprintf(f, "narf\n"); fclose(f); f = fopen("narf", "a"); printf("%ld\n", ftell(f)); fprintf(f, "troz\n"); printf("%ld\n", ftell(f)); return 0; } on macOS, FreeBSD, and Linux with glibc, this program prints 5 10 but on musl libc (Alpine Linux and probably others) this prints 0 10 By my reading of https://pubs.opengroup.org/onlinepubs/009695399/functions/fopen.html this is technically correct, specifically: > Opening a file with append mode (a as the first character in the > mode argument) shall cause all subsequent writes to the file to be > forced to the then current end-of-file, regardless of intervening > calls to fseek(). in other words, the file position doesn't really matter in append-mode files, and we can't depend on it being at all meaningful unless we perform a seek() before tell() after open(..., 'a'). Experimentally after a .write() we can do a .tell() and it'll always be reasonable, but I'm unclear from reading the specification if that's a smart thing to rely on. This matches what we do on Windows and what Python 3 does for free, so let's just be consistent. Thanks to Yuya for the idea.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
41840
d6569f1e9b37 server: allow customizing the default repo filter
Joerg Sonnenberger <joerg@bec.de>
parents:
diff changeset
     1
  $ hg init test
d6569f1e9b37 server: allow customizing the default repo filter
Joerg Sonnenberger <joerg@bec.de>
parents:
diff changeset
     2
  $ cd test
d6569f1e9b37 server: allow customizing the default repo filter
Joerg Sonnenberger <joerg@bec.de>
parents:
diff changeset
     3
  $ hg debugbuilddag '+2'
d6569f1e9b37 server: allow customizing the default repo filter
Joerg Sonnenberger <joerg@bec.de>
parents:
diff changeset
     4
  $ hg phase --public 0
d6569f1e9b37 server: allow customizing the default repo filter
Joerg Sonnenberger <joerg@bec.de>
parents:
diff changeset
     5
d6569f1e9b37 server: allow customizing the default repo filter
Joerg Sonnenberger <joerg@bec.de>
parents:
diff changeset
     6
  $ hg serve -p $HGPORT -d --pid-file=hg.pid -E errors.log
d6569f1e9b37 server: allow customizing the default repo filter
Joerg Sonnenberger <joerg@bec.de>
parents:
diff changeset
     7
  $ cat hg.pid >> $DAEMON_PIDS
d6569f1e9b37 server: allow customizing the default repo filter
Joerg Sonnenberger <joerg@bec.de>
parents:
diff changeset
     8
  $ cd ..
d6569f1e9b37 server: allow customizing the default repo filter
Joerg Sonnenberger <joerg@bec.de>
parents:
diff changeset
     9
  $ hg init test2
d6569f1e9b37 server: allow customizing the default repo filter
Joerg Sonnenberger <joerg@bec.de>
parents:
diff changeset
    10
  $ cd test2
d6569f1e9b37 server: allow customizing the default repo filter
Joerg Sonnenberger <joerg@bec.de>
parents:
diff changeset
    11
  $ hg incoming http://foo:xyzzy@localhost:$HGPORT/
d6569f1e9b37 server: allow customizing the default repo filter
Joerg Sonnenberger <joerg@bec.de>
parents:
diff changeset
    12
  comparing with http://foo:***@localhost:$HGPORT/
d6569f1e9b37 server: allow customizing the default repo filter
Joerg Sonnenberger <joerg@bec.de>
parents:
diff changeset
    13
  changeset:   0:1ea73414a91b
d6569f1e9b37 server: allow customizing the default repo filter
Joerg Sonnenberger <joerg@bec.de>
parents:
diff changeset
    14
  user:        debugbuilddag
d6569f1e9b37 server: allow customizing the default repo filter
Joerg Sonnenberger <joerg@bec.de>
parents:
diff changeset
    15
  date:        Thu Jan 01 00:00:00 1970 +0000
d6569f1e9b37 server: allow customizing the default repo filter
Joerg Sonnenberger <joerg@bec.de>
parents:
diff changeset
    16
  summary:     r0
d6569f1e9b37 server: allow customizing the default repo filter
Joerg Sonnenberger <joerg@bec.de>
parents:
diff changeset
    17
  
d6569f1e9b37 server: allow customizing the default repo filter
Joerg Sonnenberger <joerg@bec.de>
parents:
diff changeset
    18
  changeset:   1:66f7d451a68b
d6569f1e9b37 server: allow customizing the default repo filter
Joerg Sonnenberger <joerg@bec.de>
parents:
diff changeset
    19
  tag:         tip
d6569f1e9b37 server: allow customizing the default repo filter
Joerg Sonnenberger <joerg@bec.de>
parents:
diff changeset
    20
  user:        debugbuilddag
d6569f1e9b37 server: allow customizing the default repo filter
Joerg Sonnenberger <joerg@bec.de>
parents:
diff changeset
    21
  date:        Thu Jan 01 00:00:01 1970 +0000
d6569f1e9b37 server: allow customizing the default repo filter
Joerg Sonnenberger <joerg@bec.de>
parents:
diff changeset
    22
  summary:     r1
d6569f1e9b37 server: allow customizing the default repo filter
Joerg Sonnenberger <joerg@bec.de>
parents:
diff changeset
    23
  
d6569f1e9b37 server: allow customizing the default repo filter
Joerg Sonnenberger <joerg@bec.de>
parents:
diff changeset
    24
  $ killdaemons.py
d6569f1e9b37 server: allow customizing the default repo filter
Joerg Sonnenberger <joerg@bec.de>
parents:
diff changeset
    25
42106
bcf59ddc6173 test: minor cleanup to test-server-view.t
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41840
diff changeset
    26
  $ cd ..
bcf59ddc6173 test: minor cleanup to test-server-view.t
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41840
diff changeset
    27
  $ hg -R test --config server.view=immutable serve -p $HGPORT -d --pid-file=hg.pid -E errors.log
41840
d6569f1e9b37 server: allow customizing the default repo filter
Joerg Sonnenberger <joerg@bec.de>
parents:
diff changeset
    28
  $ cat hg.pid >> $DAEMON_PIDS
42106
bcf59ddc6173 test: minor cleanup to test-server-view.t
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41840
diff changeset
    29
  $ hg -R test2 incoming http://foo:xyzzy@localhost:$HGPORT/
41840
d6569f1e9b37 server: allow customizing the default repo filter
Joerg Sonnenberger <joerg@bec.de>
parents:
diff changeset
    30
  comparing with http://foo:***@localhost:$HGPORT/
d6569f1e9b37 server: allow customizing the default repo filter
Joerg Sonnenberger <joerg@bec.de>
parents:
diff changeset
    31
  changeset:   0:1ea73414a91b
d6569f1e9b37 server: allow customizing the default repo filter
Joerg Sonnenberger <joerg@bec.de>
parents:
diff changeset
    32
  tag:         tip
d6569f1e9b37 server: allow customizing the default repo filter
Joerg Sonnenberger <joerg@bec.de>
parents:
diff changeset
    33
  user:        debugbuilddag
d6569f1e9b37 server: allow customizing the default repo filter
Joerg Sonnenberger <joerg@bec.de>
parents:
diff changeset
    34
  date:        Thu Jan 01 00:00:00 1970 +0000
d6569f1e9b37 server: allow customizing the default repo filter
Joerg Sonnenberger <joerg@bec.de>
parents:
diff changeset
    35
  summary:     r0
d6569f1e9b37 server: allow customizing the default repo filter
Joerg Sonnenberger <joerg@bec.de>
parents:
diff changeset
    36
  
42106
bcf59ddc6173 test: minor cleanup to test-server-view.t
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41840
diff changeset
    37
  $ cat errors.log
41840
d6569f1e9b37 server: allow customizing the default repo filter
Joerg Sonnenberger <joerg@bec.de>
parents:
diff changeset
    38
  $ killdaemons.py