Skip to content
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
11 changes: 11 additions & 0 deletions ballerina/tests/file-test.bal
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,17 @@ function testCopyFileNonExistSource() {
}
}

@test:Config {}
function testCopyFileNonExistDir() {
error? copyResult = copy(srcFile, noDir + copyFile);
if copyResult is error {
string expectedErrMsg = "The target directory does not exist";
test:assertTrue(copyResult.message().includes(expectedErrMsg));
} else {
test:assertFail("File copy succeeded to a non-existent destination directory!");
}
}

@test:Config {}
function testGetCurrentDirectory() {
string currentDir = getCurrentDir();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,8 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IO
Path newFile = target.resolve(source.relativize(file));
try {
Files.copy(file, newFile, copyOptions);
} catch (NoSuchFileException e) {
throw e;
} catch (Exception e) {
log.debug(e.getMessage());
return SKIP_SUBTREE; // skip processing
Expand Down