[PATCH 2 of 5] tests: add a substitution for ENOENT/ERROR_FILE_NOT_FOUND messages

Matt Harbison mharbison72 at gmail.com
Sun Dec 3 12:07:59 EST 2017


On Sun, 03 Dec 2017 03:59:37 -0500, Yuya Nishihara <yuya at tcha.org> wrote:

> On Sun, 03 Dec 2017 01:54:55 -0500, Matt Harbison wrote:
>> # HG changeset patch
>> # User Matt Harbison <matt_harbison at yahoo.com>
>> # Date 1512261214 18000
>> #      Sat Dec 02 19:33:34 2017 -0500
>> # Node ID 8e58a105a6fc156673e852ec9a40f2d517fc7ceb
>> # Parent  c65000767eec5a1a159c73cd2fe7b6741a1dea84
>> tests: add a substitution for ENOENT/ERROR_FILE_NOT_FOUND messages
>
>> +# Various platform error strings, keyed on a common replacement string
>> +_errors = {
>> +    br'$ENOENT$': (
>> +        # strerror()
>> +        br'No such file or directory',
>> +
>> +        # FormatMessage(ERROR_FILE_NOT_FOUND)
>> +        br'The system cannot find the file specified',
>> +    ),
>> +}
>> +
>> +for replace, msgs in _errors.items():
>> +    substitutions.extend((m, replace) for m in msgs)
>> diff --git a/tests/test-acl.t b/tests/test-acl.t
>> --- a/tests/test-acl.t
>> +++ b/tests/test-acl.t
>> @@ -925,7 +925,7 @@
>>    bundle2-input-bundle: 4 parts total
>>    transaction abort!
>>    rollback completed
>> -  abort: No such file or directory: ../acl.config
>> +  abort: $ENOENT$: ../acl.config
>
> IIRC, this sort of messages are locale dependent on Windows, and we can't
> easily switch the Windows locale.

I'm almost positive that's the case.  A few years back, we had a bug where  
FormatMessage was defined to FormatMessageA, and was producing garbage for  
GetLastError() when a Japanese locale was used.

But given that the error message in the test output is currently in plain  
English, it would seem that we are already limited to only certain locales?

> Foozy, can you test if this series works for you?


More information about the Mercurial-devel mailing list