File: TestStdModuleSourcesMissing.py

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (72 lines) | stat: -rw-r--r-- 2,669 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
"""
Check that missing module source files are correctly handled by LLDB.
"""

from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
import os
import shutil


class TestCase(TestBase):
    # We only emulate a fake libc++ in this test and don't use the real libc++,
    # but we still add the libc++ category so that this test is only run in
    # test configurations where libc++ is actually supposed to be tested.
    @add_test_categories(["libc++"])
    @skipIf(compiler=no_match("clang"))
    @skipIfRemote
    def test(self):
        # The path to our temporary target root that contains the temporary
        # module sources.
        target_sysroot = self.getBuildArtifact("root")

        # Copy the sources to the root.
        shutil.copytree(self.getSourcePath("root"), target_sysroot)
        # Build the binary with the copied sources.
        self.build()
        # Delete the copied sources so that they are now unavailable.
        shutil.rmtree(target_sysroot)

        # Set the sysroot where our dummy libc++ used to exist. Just to make
        # sure we don't find some existing headers on the system that could
        # XPASS this test.
        self.runCmd("platform select --sysroot '" + target_sysroot + "' host")

        lldbutil.run_to_source_breakpoint(
            self, "// Set break point at this line.", lldb.SBFileSpec("main.cpp")
        )

        # Import the std C++ module and run an expression.
        # As we deleted the sources, LLDB should refuse the load the module
        # and just print the normal error we get from the expression.
        self.runCmd("settings set target.import-std-module true")
        self.expect(
            "expr v.unknown_identifier",
            error=True,
            substrs=["no member named 'unknown_identifier'"],
        )
        # Check that there is no confusing error about failing to build the
        # module.
        self.expect(
            "expr v.unknown_identifier",
            error=True,
            matching=False,
            substrs=["could not build module 'std'"],
        )

        # Test the fallback mode. It should also just print the normal
        # error but not mention a failed module build.
        self.runCmd("settings set target.import-std-module fallback")

        self.expect(
            "expr v.unknown_identifier",
            error=True,
            substrs=["no member named 'unknown_identifier'"],
        )
        self.expect(
            "expr v.unknown_identifier",
            error=True,
            matching=False,
            substrs=["could not build module 'std'"],
        )