microsoft / STL

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

Unable to run tests with `subst` drive letters #4617

Open StephanTLavavej opened 5 months ago

StephanTLavavej commented 5 months ago

Encountered by @H-G-Hristov in #4611.

Possibly related to the codepaths that I changed in #4395.

Confirmed by @AlexGuteniev on Discord, quoting his repro:

C:\Project\STL\out\x64>subst /?
Associates a path with a drive letter.

SUBST [drive1: [drive2:]path]
SUBST drive1: /D

  drive1:        Specifies a virtual drive to which you want to assign a path.
  [drive2:]path  Specifies a physical drive and path you want to assign to
                 a virtual drive.
  /D             Deletes a substituted (virtual) drive.

Type SUBST with no parameters to display a list of current virtual drives.

C:\Project\STL\out\x64>subst D: C:\Project

C:\Project\STL\out\x64>D:

D:\>cd stl\out\x64

D:\STL\out\x64>python tests\utils\stl-lit\stl-lit.py ..\..\tests\std\tests\VSO_0000000_vector_algorithms -v
stl-lit.py: D:\STL\tests\std\lit.cfg:4: fatal: You seem to be running Lit directly -- you should be running Lit through <build>/tests/utils/stl-lit/stl-lit.py, which will ensure that the right Lit configuration file is used.
AlexGuteniev commented 5 months ago

Possibly related to the codepaths that I changed in #4395.

No.

The problem is in generated Python script at out\x64\tests\utils\stl-lit\stl-lit.py:

#!/usr/bin/env python
# -*- coding: utf-8 -*-

#===----------------------------------------------------------------------===##
#
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
#===----------------------------------------------------------------------===##

import os
import sys

config_map = {}

def map_config(source_dir, site_config):
    global config_map
    source_dir = os.path.realpath(source_dir)
    source_dir = os.path.normcase(source_dir)
    site_config = os.path.normpath(site_config)
    config_map[source_dir] = site_config

# Make sure we can find the lit package.
sys.path.insert(0, os.path.join("D:/STL/llvm-project/llvm", 'utils', 'lit'))

map_config("D:/STL/llvm-project/libcxx/test/lit.cfg.py", "D:/STL/out/x64/tests/libcxx/lit.site.cfg")
map_config("D:/STL/tests/libcxx/lit.cfg", "D:/STL/out/x64/tests/libcxx/lit.site.cfg")
map_config("D:/STL/tests/std/lit.cfg", "D:/STL/out/x64/tests/std/lit.site.cfg")
map_config("D:/STL/tests/tr1/lit.cfg", "D:/STL/out/x64/tests/tr1/lit.site.cfg")

builtin_parameters= {}
builtin_parameters['config_map'] = config_map

if __name__=='__main__':
    from lit.main import main
    main(builtin_parameters)

The paths like in map_config("D:/STL/llvm-project/libcxx/test/lit.cfg.py", "D:/STL/out/x64/tests/libcxx/lit.site.cfg") are substitute paths.

However, this operation source_dir = os.path.realpath(source_dir) converts them to unsubst paths.

Commenting this line out works around the issue.

StephanTLavavej commented 5 months ago

Thanks! It seems like if one side is using the realpath transformation, then the other side should too.

AlexGuteniev commented 5 months ago

Yes, but there are multiple "other sides". Changing site_config above to use realpath transformation isn't helpful, apparently should also use the transformations to paths that go as lookup values.