Skip to content

Avoid calling os.chdir() in test. #2990

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions lldb/test/API/lang/swift/path_with_colons/Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
SWIFT_SOURCES := main.swift

include Makefile.rules
all:
$(MAKE) -C "pro:ject"
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def do_test(self):
copied_src = os.path.join(colon_dir, 'main.swift')
dst = os.path.join(colon_dir, 'a.out')
dst_makefile = os.path.join(colon_dir, 'Makefile')
exe = os.path.join(colon_dir, 'a.out')

if not os.path.exists(colon_dir):
os.makedirs(colon_dir)
Expand All @@ -53,26 +54,23 @@ def do_test(self):
# clean slate for the next test case.
def cleanup():
shutil.rmtree(colon_dir)
os.chdir(self.getSourceDir())

# Execute the cleanup function during test case tear down.
self.addTearDownHook(cleanup)

f = open(dst_makefile, 'w')
f.write('''
LEVEL = ../../../../make
SWIFT_SOURCES := main.swift
include $(LEVEL)/Makefile.rules
include Makefile.rules
''')
f.close()

shutil.copy(src, copied_src)

os.chdir(colon_dir)
self.build()

# Create the target
target = self.dbg.CreateTarget(self.getBuildArtifact())
target = self.dbg.CreateTarget(exe)
self.assertTrue(target, VALID_TARGET)

# Don't allow ansi highlighting to interfere with the output.
Expand Down