Skip to content

test: Modify UserApplyPatch to assert on substring

James Liu requested to merge jliu-fix-apply-patch-assertion into master

Issue: #5973 (closed)

Our CI tests against Git's master and next branches are failing due to changes in 37ce9735 (builtin/am: allow disabling conflict advice) of the Git project. These changed altered how the patch conflict advice is displayed:

  • The conflict advice is now selectively shown depending on whether the advice.mergeConflict option is enabled. This option was introduced in the prior commit, and is not available in stable versions of Git.
  • Since it now uses the advice machinery, the content is printed to stderr, not stdout.

Unfortunately, this means we have to adjust how we assert the error in the tests rather than tweak Git options so stable and master/next behave the same:

  • Disabling advice.mergeConflict has no effect in stable Git since the advice was displayed with hardcoded print statements. Doing this in master/next has no effect because the advice gets routed to stderr, which doesn't get asserted on anyway.
  • Explicitly enabling advice.mergeConflict doesn't work either for the same reason.
  • Setting --resolvemsg= in the CLI flags when invoking git am also doesn't work. Stable Git prints this value with an extra newline while master/next does not, since it also uses the advice machinery.

Therefore, add a new gRPC test helper that can assert on the status code of an error, and also perform a substring match against the error message. This allows us to remove the advice section of the error and only ensure the important bits match.

Merge request reports