Refactor update_checks into a more generic lit_autoupdate (#2277)

I've refactored the script in order to make it work in more contexts, which is why the delta is lost. I've actually refactored a significant amount with the intent of making the logic easier to understand, because I was also adjusting bits of it.

Some key notes:

- Removes the multi-pass update that was dealing with unfixed line numbers in explorer (I think the current script should work in one pass)
  - Fixed explorer to handle multiple line numbers on the same line (turns out we can rely on local format for line numbers).
- Using execv instead of imports because making Python imports work in a setup like this feels like it's not worth it; only a nuisance.
- Adding __init__.py to satisfy mypy, which otherwise considers the lit_autoupdate.py scripts to be issues.
- Using py because I was thinking sh would be more platform-dependent. py should port better to Windows.
- Getting rid of [[ID#]] capture groups in the semantics-ir tests because with the autoupdate it's kind of moot (also, hard to autogenerate the pairs without relying on the %### value).

Note this does mean tests switch to more of a "make a change, see which tests change" setup. I don't know that that's a _bad_ thing though -- it's pretty much how tests are being written right now, which is why I went down this rabbit hole. It's a nuisance to make a change then _manually_ have to update a bunch of code.

My intent is to use this for to convert parse-tree tests to lit, but I wanted to do this with _existing_ tests first as a proof of concept and to make sure there's agreement.
This commit is contained in:
Jon Ross-Perkins
2022-10-12 15:01:38 -07:00
committed by GitHub
parent 61552a788b
commit 55e124a667
30 changed files with 602 additions and 338 deletions
+3 -2
View File
@@ -3,12 +3,13 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// RUN: %{carbon} dump semantics-ir %s 2>&1 | %{FileCheck-strict} %s
// AUTOUPDATE: %{carbon} dump semantics-ir %s
// CHECK:{
// CHECK: Function(
// CHECK: %[[ID0:[0-9]+]],
// CHECK: %0,
// CHECK: {
// CHECK: }),
// CHECK: SetName(`Foo`, %[[ID0]]),
// CHECK: SetName(`Foo`, %0),
// CHECK:}
fn Foo() {}