import lldb
from lldbsuite.test.lldbtest import *
from lldbsuite.test.decorators import *
import lldbsuite.test.lldbutil as lldbutil
import unittest2

class TestSwiftExtraClangFlags(TestBase):

    mydir = TestBase.compute_mydir(__file__)
    
    def setUp(self):
        TestBase.setUp(self)

    @skipUnlessDarwin
    @swiftTest
    @add_test_categories(["swiftpr"])
    def test_sanity(self):
        self.build()
        lldbutil.run_to_source_breakpoint(self, "break here",
                                          lldb.SBFileSpec('main.swift'))
        self.expect("frame var foo", "sanity check", substrs=['(Foo)'])
        self.expect("expr FromOverlay(i: 23)", error=True)

    @skipUnlessDarwin
    @swiftTest
    @add_test_categories(["swiftpr"])
    def test_extra_clang_flags(self):
        """
        Test that a debug-only module map can be installed by injecting a
        VFS overlay using target.swift-extra-clang-flags.
        """
        self.build()
        # FIXME: this doesn't work if LLDB's build dir contains a space.
        overlay = self.getBuildArtifact('overlay.yaml')
        self.addTearDownHook(
            lambda: self.runCmd("settings clear target.swift-extra-clang-flags"))
        self.expect('settings set -- target.swift-extra-clang-flags '+
                    '"-ivfsoverlay %s"' % overlay)
        with open(overlay, 'w+') as f:
            import os
            f.write("""
{
  'version': 0,
  'roots': [
    { 'name': '"""+os.getcwd()+"""/nonmodular', 'type': 'directory',
      'contents': [
        { 'name': 'module.modulemap', 'type': 'file',
          'external-contents': '"""+os.path.join(os.getcwd(),
                                                 'overlaid.map')+"""'
        }
      ]
    }
  ]
}
""")
        lldbutil.run_to_source_breakpoint(self, "break here",
                                          lldb.SBFileSpec('main.swift'))
        self.expect("frame var foo", "sanity check", substrs=['(Foo)'])
        self.expect("expr FromOverlay(i: 23)", substrs=['(FromOverlay)', '23'])

import lldb
from lldbsuite.test.lldbtest import *
from lldbsuite.test.decorators import *
import lldbsuite.test.lldbutil as lldbutil
import unittest2

class TestSwiftExtraClangFlags(TestBase):

    mydir = TestBase.compute_mydir(__file__)

    def setUp(self):
        TestBase.setUp(self)

    @skipUnlessDarwin
    @swiftTest
    def test_sanity(self):
        self.build()
        lldbutil.run_to_source_breakpoint(self, "break here",
                                          lldb.SBFileSpec('main.swift'))
        self.expect("frame var foo", "sanity check", substrs=['(Foo)'])
        self.expect("expr FromOverlay(i: 23)", error=True)

    @skipUnlessDarwin
    @swiftTest
    def test_extra_clang_flags(self):
        """
        Test that a debug-only module map can be installed by injecting a
        VFS overlay using target.swift-extra-clang-flags.
        """
        self.build()
        # FIXME: this doesn't work if LLDB's build dir contains a space.
        overlay = self.getBuildArtifact('overlay.yaml')
        self.addTearDownHook(
            lambda: self.runCmd("settings clear target.swift-extra-clang-flags"))
        self.expect('settings set -- target.swift-extra-clang-flags '+
                    '"-ivfsoverlay %s"' % overlay)
        with open(overlay, 'w+') as f:
            import os
            f.write("""
{
  'version': 0,
  'roots': [
    { 'name': '"""+os.getcwd()+"""/nonmodular', 'type': 'directory',
      'contents': [
        { 'name': 'module.modulemap', 'type': 'file',
          'external-contents': '"""+os.path.join(os.getcwd(),
                                                 'overlaid.map')+"""'
        }
      ]
    }
  ]
}
""")
        lldbutil.run_to_source_breakpoint(self, "break here",
                                          lldb.SBFileSpec('main.swift'))
        self.expect("frame var foo", "sanity check", substrs=['(Foo)'])
        self.expect("expr FromOverlay(i: 23)", substrs=['(FromOverlay)', '23'])

Remove swiftpr category