[SERVER-42344] The `errorcodes.py` script should not be checking for duplicate error codes in unit-tests Created: 23/Jul/19  Updated: 06/Dec/22  Resolved: 07/Jul/20

Status: Closed
Project: Core Server
Component/s: Build
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor - P4
Reporter: Kaloian Manassiev Assignee: Backlog - Service Architecture
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Service Arch
Operating System: ALL
Participants:

 Description   

It looks like the `errorcodes.py` script is checking for error codes in all source files, including unit-tests. This makes it difficult to ensure in tests whether a specific error code is returned by a function. For example a test, which looks like this:

ASSERT_EQ(ErrorCodes::Error(50993), decision.getAbortStatus()->code());

Fails to compile with this error:

[1/3] Checking error codes and waiting for next compile to finish
FAILED: build/compiler_timestamps/error_code_check.timestamp
cmd /c C:\Python37\python.exe buildscripts/errorcodes.py -q --list-files  &&  ( echo "" > build\compiler_time
DUPLICATE IDS: 50993
  src/mongo/db/s/transaction_coordinator_test.cpp:469:33:ErrorCodes::Error(50993
  src/mongo/db/s/transaction_coordinator_util.cpp:551:66:ErrorCodes::Error(50993
ok: False
next: 51244
 
ERRORS DETECTED. To correct, run "buildscripts/errorcodes.py --fix" to replace zero codes.
Other errors require manual correction.



 Comments   
Comment by Mira Carey [ 07/Jul/20 ]

A couple of thoughts here:

  1. there's a workaround, if not an aesthetically pleasing
  2. another option would be to make the error code available in a header and check for it that way

A such, closing wont fix

Comment by Andrew Morrow (Inactive) [ 30/Jul/19 ]

kaloian.manassiev - You can work around this by moving the error code out of the ErrorCodes::Error expression:

auto ec = 50993;
ASSERT_EQ(ErrorCodes::Error(ec), decision...);

I realize that may not be the most aesthetically pleasing fix, but it will work.

Generated at Thu Feb 08 05:00:14 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.