Skip to content

Commit

Permalink
Merge branch 'stdout' (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
knewjade committed Mar 27, 2022
2 parents 1cde8db + 90094b1 commit bb500a8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
12 changes: 9 additions & 3 deletions src/main/java/entry/path/output/MyFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,15 @@ public MyFile(String path, boolean outputToConsole) {
}

public void mkdirs() throws FinderInitializeException {
// 親ディレクトリがない場合は作成
if (!file.getParentFile().exists()) {
boolean mkdirsSuccess = file.getParentFile().mkdirs();
// 親ディレクトリが有効でない場合はエラー
File parentFile = file.getParentFile();
if (parentFile == null) {
throw new FinderInitializeException("Parent directory is not invalid: OutputBase=" + path);
}

// ベースディレクトリがない場合は作成
if (!parentFile.exists()) {
boolean mkdirsSuccess = parentFile.mkdirs();
if (!mkdirsSuccess) {
throw new FinderInitializeException("Failed to make output directory: OutputBase=" + path);
}
Expand Down
11 changes: 10 additions & 1 deletion src/test/java/_usecase/path/PathIrregularCaseTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import _usecase.ConfigFileHelper;
import _usecase.Log;
import _usecase.path.files.OutputFileHelper;
import _usecase.RunnerHelper;
import _usecase.path.files.OutputFileHelper;
import core.field.Field;
import core.field.FieldFactory;
import core.field.FieldView;
Expand Down Expand Up @@ -657,4 +657,13 @@ void invalidHold() throws Exception {
.contains(command)
.contains("Cannot parse hold option: value=INVALID [FinderParseException]");
}

@Test
void unsupportedConsoleOutput() throws Exception {
String command = "path -t v115@9gB8HeC8GeD8FeC8QeAgH -p *! -o -";
Log log = RunnerHelper.runnerCatchingLog(() -> EntryPointMain.main(command.split(" ")));

assertThat(log.getReturnCode()).isNotEqualTo(0);
assertThat(log.getError()).contains("Parent directory is not invalid");
}
}

0 comments on commit bb500a8

Please sign in to comment.