From fcbefbedc4de71688d9898683d2c2c4abcbedfe6 Mon Sep 17 00:00:00 2001 From: Shayne Fletcher Date: Mon, 29 Nov 2021 13:16:14 -0800 Subject: [PATCH] make the typecheck tests v2 compatible Summary: There are a bunch of hack typechecker tests based around some Python and shell scripts that very much want to be run from fbsource/fbcode (run the tests, if the output differs, offer to automate updating the expect files sort of thing). buck1 arranges for them to be run from fbcode but the current behavior of buck2 is to run from fbsource. I explored one way of achieving buck1/buck2 compatibility in D32629408 but this turns out to be way hard and not a lot to be gained today for much work. A much easier "hack" that sees us on our way today is given here. Note that even this isn't the whole story. These tests are also executed under dune (presumably for OSS) from some ancestor of fbcode and there is special case logic in 'verify.py' and 'review.sh' to account for that. So, care is taken here to only adjust the working directory in the case of buck2. Some related chat: - https://fb.workplace.com/groups/buck2users/permalink/3023616267894734/ - https://fb.workplace.com/groups/buck2prototyping/posts/2800385523592263/?comment_id=2800401463590669 Reviewed By: ndmitchell Differential Revision: D32698005 fbshipit-source-id: 11fab5789240ec3bebcd8f310d663aa2e606e990 --- hphp/hack/test/verify.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/hphp/hack/test/verify.py b/hphp/hack/test/verify.py index 5487f187ef8..2f896e323f6 100755 --- a/hphp/hack/test/verify.py +++ b/hphp/hack/test/verify.py @@ -871,6 +871,22 @@ if __name__ == "__main__": if not os.path.isfile(args.program): raise Exception("Could not find program at %s" % args.program) + # 'args.test_path' is a path relative to the current working + # directory. buck1 runs this test from fbsource/fbocde, buck2 runs + # it from fbsource. + if os.path.basename(os.getcwd()) != "fbsource": + + # If running under buck1 then we are in fbcode, if running + # under dune then some ancestor directory of fbcode. These two + # cases are handled by the logic of this script and + # 'review.sh' and there are no adjustments to make. + pass + else: + + # The buck2 case has us running in fbsource. This puts us in + # fbcode. + os.chdir("fbcode") + files: List[str] = list_test_files( args.test_path, args.disabled_extension, args.in_extension ) -- 2.11.4.GIT