microsoft / STL

MSVC's implementation of the C++ Standard Library.
Other
9.88k stars 1.45k forks source link

Block building Tests in wrong command prompt #4717

Closed fsb4000 closed 1 week ago

fsb4000 commented 2 weeks ago

Fixes #4639

изображение изображение изображение изображение изображение изображение изображение

StephanTLavavej commented 2 weeks ago

Thanks, this is super awesome and will prevent a common problem for contributors! :heart_eyes_cat:

I pushed a major simplification of the logic and improved the output:

D:\GitHub\STL\out\x64>cl
Microsoft (R) C/C++ Optimizing Compiler Version 19.41.33923 for x86
Copyright (C) Microsoft Corporation.  All rights reserved.

usage: cl [ option... ] filename... [ /link linkoption... ]

D:\GitHub\STL\out\x64>python tests\utils\stl-lit\stl-lit.py -o testing.log -Dnotags=ASAN --order=random --succinct %STL%\tests\std\tests\P0295R0_gcd_lcm
Target platform mismatch: the STL was built for x64 but tested for x86.

This works because CMake's configure_file transformations bake build_platform = '$ENV{Platform}' into out\x64\tests\utils\stl-lit\stl-lit.py containing:

def assert_same_platform_for_build_and_test():
    build_platform = 'x64'
    test_platform = os.getenv('Platform', default='')

I also verified the reverse failure case, and successful cases.

StephanTLavavej commented 2 weeks ago

I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed.

StephanTLavavej commented 1 week ago

Thanks for preventing this common early headache for contributors! :adhesive_bandage: :hospital: :tada: