Skip to content
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

[ISSUE #7444] Fix testCalculateFileSizeInPath test can not rerun in same environment #7445

Merged
merged 2 commits into from
Oct 13, 2023
Merged
Changes from 1 commit
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
15 changes: 13 additions & 2 deletions common/src/test/java/org/apache/rocketmq/common/UtilAllTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,19 @@ public void testCalculateFileSizeInPath() throws Exception {

assertEquals(1313 * 4, UtilAll.calculateFileSizeInPath(baseFile));

// clear all file
baseFile.deleteOnExit();
deleteFolder(baseFile);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果某次fail了,是不是就无法执行到删除逻辑。放在test开始前,每次执行先删除会不会更好

}

public static void deleteFolder(File folder) {
if (folder.isDirectory()) {
File[] files = folder.listFiles();
if (files != null) {
for (File file : files) {
deleteFolder(file);
}
}
}
folder.delete();
}

private void writeFixedBytesToFile(File file, int size) throws Exception {
Expand Down
Loading