embulk 0.8.18-java → 0.8.19-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -0
- data/build.gradle +10 -3
- data/embulk-cli/build.gradle +2 -0
- data/embulk-cli/src/main/bat/selfrun.bat +98 -0
- data/embulk-cli/src/main/java/org/embulk/cli/EmbulkExample.java +82 -0
- data/embulk-cli/src/main/java/org/embulk/cli/EmbulkMigrate.java +458 -0
- data/embulk-cli/src/main/java/org/embulk/cli/EmbulkNew.java +419 -0
- data/embulk-cli/src/main/java/org/embulk/cli/EmbulkSelfUpdate.java +248 -0
- data/embulk-cli/src/main/sh/selfrun.sh +0 -103
- data/embulk-cli/src/test/java/org/embulk/cli/SelfrunTest.java +158 -143
- data/embulk-core/build.gradle +2 -2
- data/embulk-core/src/main/java/org/embulk/EmbulkVersion.java +109 -0
- data/embulk-core/src/main/java/org/embulk/exec/GuessExecutor.java +11 -0
- data/embulk-core/src/main/java/org/embulk/exec/PreviewExecutor.java +29 -3
- data/embulk-core/src/main/java/org/embulk/exec/SamplingParserPlugin.java +47 -13
- data/embulk-core/src/main/java/org/embulk/spi/FileInputRunner.java +6 -3
- data/embulk-core/src/main/java/org/embulk/spi/PageBuilder.java +385 -64
- data/embulk-core/src/main/java/org/embulk/spi/TempFileSpace.java +2 -1
- data/embulk-core/src/test/java/org/embulk/spi/TestPageBuilderReader.java +62 -0
- data/embulk-docs/src/built-in.rst +59 -21
- data/embulk-docs/src/customization.rst +8 -8
- data/embulk-docs/src/developers/index.rst +45 -0
- data/embulk-docs/src/index.rst +11 -7
- data/embulk-docs/src/recipe.rst +1 -1
- data/embulk-docs/src/recipe/{scheduled-csv-load-to-elasticsearch-kibana4.rst → scheduled-csv-load-to-elasticsearch-kibana5.rst} +26 -24
- data/embulk-docs/src/release.rst +1 -0
- data/embulk-docs/src/release/release-0.4.0.rst +1 -1
- data/embulk-docs/src/release/release-0.5.0.rst +1 -1
- data/embulk-docs/src/release/release-0.6.0.rst +1 -1
- data/embulk-docs/src/release/release-0.6.20.rst +1 -1
- data/embulk-docs/src/release/release-0.8.19.rst +43 -0
- data/embulk-standards/src/main/java/org/embulk/standards/CsvParserPlugin.java +2 -2
- data/embulk-standards/src/main/java/org/embulk/standards/LocalFileInputPlugin.java +30 -1
- data/embulk-standards/src/test/java/org/embulk/standards/guess/TestCsvGuessPlugin.java +10 -0
- data/embulk-standards/src/test/java/org/embulk/standards/preview/TestFilePreview.java +73 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/guess/csv/test/test_skip_suggest_if_empty_sample_records.csv +5 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/guess/csv/test/test_skip_suggest_if_empty_sample_records_guessed.yml +2 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/guess/csv/test/test_skip_suggest_if_empty_sample_records_seed.yml +1 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/preview/file/test/test_sample_buffer_bytes.csv +5 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/preview/file/test/test_sample_buffer_bytes_exec.yml +1 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/preview/file/test/test_sample_buffer_bytes_load.yml +19 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/preview/file/test/test_sample_buffer_bytes_previewed.csv +1 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/preview/file/test/test_simple.csv +5 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/preview/file/test/test_simple_load.yml +19 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/preview/file/test/test_simple_previewed.csv +4 -0
- data/embulk-test/src/main/java/org/embulk/test/PreviewResultInputPlugin.java +65 -0
- data/embulk-test/src/main/java/org/embulk/test/TestingBulkLoader.java +5 -0
- data/embulk-test/src/main/java/org/embulk/test/TestingEmbulk.java +59 -2
- data/embulk.gemspec +2 -1
- data/lib/embulk/command/embulk_run.rb +11 -49
- data/lib/embulk/data/new/README.md.vm +106 -0
- data/lib/embulk/data/new/{gitignore.erb → gitignore.vm} +3 -3
- data/lib/embulk/data/new/java/{build.gradle.erb → build.gradle.vm} +8 -8
- data/lib/embulk/data/new/java/{decoder.java.erb → decoder.java.vm} +6 -4
- data/lib/embulk/data/new/java/{encoder.java.erb → encoder.java.vm} +7 -5
- data/lib/embulk/data/new/java/{file_input.java.erb → file_input.java.vm} +9 -7
- data/lib/embulk/data/new/java/{file_output.java.erb → file_output.java.vm} +7 -5
- data/lib/embulk/data/new/java/{filter.java.erb → filter.java.vm} +4 -3
- data/lib/embulk/data/new/java/{formatter.java.erb → formatter.java.vm} +5 -4
- data/lib/embulk/data/new/java/{input.java.erb → input.java.vm} +6 -4
- data/lib/embulk/data/new/java/{output.java.erb → output.java.vm} +7 -5
- data/lib/embulk/data/new/java/{parser.java.erb → parser.java.vm} +5 -4
- data/lib/embulk/data/new/java/plugin_loader.rb.vm +3 -0
- data/lib/embulk/data/new/java/test.java.vm +5 -0
- data/lib/embulk/data/new/ruby/decoder_guess.rb.vm +25 -0
- data/lib/embulk/data/new/ruby/{filter.rb.erb → filter.rb.vm} +2 -2
- data/lib/embulk/data/new/ruby/{formatter.rb.erb → formatter.rb.vm} +2 -2
- data/lib/embulk/data/new/ruby/gemspec.vm +20 -0
- data/lib/embulk/data/new/ruby/{input.rb.erb → input.rb.vm} +10 -10
- data/lib/embulk/data/new/ruby/{output.rb.erb → output.rb.vm} +7 -7
- data/lib/embulk/data/new/ruby/{parser.rb.erb → parser.rb.vm} +2 -2
- data/lib/embulk/data/new/ruby/parser_guess.rb.vm +65 -0
- data/lib/embulk/guess/csv.rb +5 -0
- data/lib/embulk/version.rb +22 -1
- metadata +55 -35
- data/lib/embulk/command/embulk_example.rb +0 -33
- data/lib/embulk/command/embulk_generate_bin.rb +0 -62
- data/lib/embulk/command/embulk_migrate_plugin.rb +0 -244
- data/lib/embulk/command/embulk_new_plugin.rb +0 -126
- data/lib/embulk/command/embulk_selfupdate.rb +0 -121
- data/lib/embulk/data/new/README.md.erb +0 -111
- data/lib/embulk/data/new/java/plugin_loader.rb.erb +0 -3
- data/lib/embulk/data/new/java/test.java.erb +0 -5
- data/lib/embulk/data/new/ruby/decoder_guess.rb.erb +0 -25
- data/lib/embulk/data/new/ruby/gemspec.erb +0 -20
- data/lib/embulk/data/new/ruby/parser_guess.rb.erb +0 -65
@@ -1,106 +1,3 @@
|
|
1
|
-
|
2
|
-
: <<BAT
|
3
|
-
@echo off
|
4
|
-
|
5
|
-
setlocal
|
6
|
-
|
7
|
-
set this=%~f0
|
8
|
-
set java_args=
|
9
|
-
set jruby_args=
|
10
|
-
set default_optimize=
|
11
|
-
set overwrite_optimize=
|
12
|
-
set status=
|
13
|
-
set error=
|
14
|
-
set args=
|
15
|
-
|
16
|
-
rem In jar file, cannot goto ahread for some reason.
|
17
|
-
|
18
|
-
for %%a in ( %* ) do (
|
19
|
-
call :check_arg %%a
|
20
|
-
)
|
21
|
-
|
22
|
-
if "%error%" == "true" exit /b 1
|
23
|
-
|
24
|
-
set optimize=false
|
25
|
-
if "%overwrite_optimize%" == "true" (
|
26
|
-
set optimize=true
|
27
|
-
) else (
|
28
|
-
if "%default_optimize%" == "true" (
|
29
|
-
if not "%overwrite_optimize%" == "false" (
|
30
|
-
set optimize=true
|
31
|
-
)
|
32
|
-
)
|
33
|
-
)
|
34
|
-
|
35
|
-
if "%optimize%" == "true" (
|
36
|
-
set java_args=-XX:+AggressiveOpts -XX:+UseConcMarkSweepGC %java_args%
|
37
|
-
) else (
|
38
|
-
set java_args=-XX:+AggressiveOpts -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -Xverify:none %java_args%
|
39
|
-
)
|
40
|
-
|
41
|
-
java %java_args% -jar %this% %jruby_args% %args%
|
42
|
-
|
43
|
-
endlocal
|
44
|
-
|
45
|
-
exit /b %ERRORLEVEL%
|
46
|
-
|
47
|
-
:check_arg
|
48
|
-
set arg=%*
|
49
|
-
|
50
|
-
rem Remove double quotations
|
51
|
-
set p1=%arg:~0,1%
|
52
|
-
set p1=%p1:"=%
|
53
|
-
set p2=%arg:~-1,1%
|
54
|
-
set p2=%p2:"=%
|
55
|
-
set arg=%p1%%arg:~1,-1%%p2%
|
56
|
-
|
57
|
-
if "%status%" == "rest" (
|
58
|
-
set args=%args% %arg%
|
59
|
-
|
60
|
-
) else if "%status%" == "read" (
|
61
|
-
call :read_file %arg%
|
62
|
-
|
63
|
-
) else if "%arg%" == "-J+O" (
|
64
|
-
set overwrite_optimize=true
|
65
|
-
set status=rest
|
66
|
-
|
67
|
-
) else if "%arg%" == "-J-O" (
|
68
|
-
set overwrite_optimize=false
|
69
|
-
set status=rest
|
70
|
-
|
71
|
-
) else if "%arg:~0,2%" == "-J" (
|
72
|
-
if not "%arg:~2%" == "" (
|
73
|
-
set java_args=%java_args% %arg:~2%
|
74
|
-
) else (
|
75
|
-
set status=read
|
76
|
-
)
|
77
|
-
|
78
|
-
) else if "%arg:~0,2%" == "-R" (
|
79
|
-
set jruby_args=%jruby_args% %arg%
|
80
|
-
|
81
|
-
) else if "%arg%" == "run" (
|
82
|
-
set default_optimize=true
|
83
|
-
set args=%args% %arg%
|
84
|
-
set status=rest
|
85
|
-
|
86
|
-
) else (
|
87
|
-
set args=%args% %arg%
|
88
|
-
set status=rest
|
89
|
-
)
|
90
|
-
exit /b
|
91
|
-
|
92
|
-
:read_file
|
93
|
-
if not exist "%~1" (
|
94
|
-
echo "failed to load java argument file."
|
95
|
-
set error=true
|
96
|
-
) else (
|
97
|
-
for /f "delims=" %%i in (%~1) do set java_args=%java_args% %%i
|
98
|
-
)
|
99
|
-
set status=
|
100
|
-
exit /b
|
101
|
-
|
102
|
-
BAT
|
103
|
-
|
104
1
|
java_args=""
|
105
2
|
jruby_args=""
|
106
3
|
default_optimize=""
|
@@ -6,13 +6,13 @@ import java.io.BufferedReader;
|
|
6
6
|
import java.io.BufferedWriter;
|
7
7
|
import java.io.File;
|
8
8
|
import java.io.FileOutputStream;
|
9
|
-
import java.io.IOException;
|
10
9
|
import java.io.InputStreamReader;
|
10
|
+
import java.io.IOException;
|
11
11
|
import java.io.OutputStreamWriter;
|
12
12
|
import java.nio.charset.Charset;
|
13
|
+
import java.nio.file.Files;
|
13
14
|
import java.nio.file.FileSystem;
|
14
15
|
import java.nio.file.FileSystems;
|
15
|
-
import java.nio.file.Files;
|
16
16
|
import java.nio.file.StandardOpenOption;
|
17
17
|
import java.util.Arrays;
|
18
18
|
import java.util.List;
|
@@ -20,237 +20,247 @@ import java.util.List;
|
|
20
20
|
import org.junit.BeforeClass;
|
21
21
|
import org.junit.Test;
|
22
22
|
|
23
|
-
|
24
23
|
public class SelfrunTest {
|
25
|
-
|
26
|
-
private static File testSelfrun;
|
24
|
+
private static File testSelfrunFile;
|
27
25
|
|
28
26
|
@BeforeClass
|
29
27
|
public static void prepare() throws Exception {
|
30
|
-
File
|
31
|
-
FileSystem
|
32
|
-
String line = new String(Files.readAllBytes(fs.getPath(selfrun.getAbsolutePath())), Charset.defaultCharset());
|
28
|
+
final File originalSelfrunFile = findSelfrun();
|
29
|
+
final FileSystem fileSystem = FileSystems.getDefault();
|
33
30
|
|
34
|
-
File thisFolder = new File(
|
35
|
-
|
31
|
+
final File thisFolder = new File(
|
32
|
+
SelfrunTest.class.getResource("/org/embulk/cli/SelfrunTest.class").toURI()).getParentFile();
|
33
|
+
testSelfrunFile = new File(
|
34
|
+
thisFolder, System.getProperty("file.separator").equals("\\") ? "selfrun.bat" : "selfrun.sh");
|
36
35
|
|
37
|
-
File classpath = thisFolder.getParentFile().getParentFile().getParentFile();
|
38
|
-
|
36
|
+
final File classpath = thisFolder.getParentFile().getParentFile().getParentFile();
|
37
|
+
final String line =
|
38
|
+
new String(Files.readAllBytes(fileSystem.getPath(originalSelfrunFile.getAbsolutePath())),
|
39
|
+
Charset.defaultCharset())
|
40
|
+
.replaceAll("java ",
|
41
|
+
"java -classpath "
|
42
|
+
+ classpath.getAbsolutePath().replaceAll("\\\\", "\\\\\\\\")
|
43
|
+
+ " org.embulk.cli.DummyMain ");
|
39
44
|
|
40
45
|
// Modify selfrun so that arguments are written in 'args.txt' .
|
41
|
-
Files.write(
|
42
|
-
|
43
|
-
|
46
|
+
Files.write(fileSystem.getPath(testSelfrunFile.getAbsolutePath()),
|
47
|
+
line.getBytes(Charset.defaultCharset()),
|
48
|
+
StandardOpenOption.CREATE);
|
49
|
+
|
50
|
+
if (!testSelfrunFile.setExecutable(true)) {
|
51
|
+
throw new Exception("Cannot set the copied selfrun file executable..");
|
44
52
|
}
|
45
53
|
}
|
46
54
|
|
47
|
-
|
48
55
|
@Test
|
49
56
|
public void testNoArgument() throws Exception {
|
50
57
|
List<String> args = execute();
|
51
58
|
assertEquals(Arrays.asList(
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
+
"-XX:+AggressiveOpts",
|
60
|
+
"-XX:+TieredCompilation",
|
61
|
+
"-XX:TieredStopAtLevel=1",
|
62
|
+
"-Xverify:none",
|
63
|
+
"-jar",
|
64
|
+
testSelfrunFile.getAbsolutePath()),
|
65
|
+
args);
|
59
66
|
}
|
60
67
|
|
61
68
|
@Test
|
62
69
|
public void testArguments() throws Exception {
|
63
70
|
List<String> args = execute("a1", "a2", "\"a3=v3\"");
|
64
71
|
assertEquals(Arrays.asList(
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
72
|
+
"-XX:+AggressiveOpts",
|
73
|
+
"-XX:+TieredCompilation",
|
74
|
+
"-XX:TieredStopAtLevel=1",
|
75
|
+
"-Xverify:none",
|
76
|
+
"-jar",
|
77
|
+
testSelfrunFile.getAbsolutePath(),
|
78
|
+
"a1",
|
79
|
+
"a2",
|
80
|
+
"a3=v3"),
|
81
|
+
args);
|
75
82
|
}
|
76
83
|
|
77
84
|
@Test
|
78
85
|
public void testRun() throws Exception {
|
79
86
|
List<String> args = execute("run", "a1");
|
80
87
|
assertEquals(Arrays.asList(
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
+
"-XX:+AggressiveOpts",
|
89
|
+
"-XX:+UseConcMarkSweepGC",
|
90
|
+
"-jar",
|
91
|
+
testSelfrunFile.getAbsolutePath(),
|
92
|
+
"run",
|
93
|
+
"a1"),
|
94
|
+
args);
|
88
95
|
}
|
89
96
|
|
90
97
|
@Test
|
91
98
|
public void testJpO() throws Exception {
|
92
99
|
List<String> args = execute("-J+O", "a1", "a2");
|
93
100
|
assertEquals(Arrays.asList(
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
+
"-XX:+AggressiveOpts",
|
102
|
+
"-XX:+UseConcMarkSweepGC",
|
103
|
+
"-jar",
|
104
|
+
testSelfrunFile.getAbsolutePath(),
|
105
|
+
"a1",
|
106
|
+
"a2"),
|
107
|
+
args);
|
101
108
|
}
|
102
109
|
|
103
110
|
@Test
|
104
111
|
public void testJmO() throws Exception {
|
105
112
|
List<String> args = execute("-J-O", "a1", "a2");
|
106
113
|
assertEquals(Arrays.asList(
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
114
|
+
"-XX:+AggressiveOpts",
|
115
|
+
"-XX:+TieredCompilation",
|
116
|
+
"-XX:TieredStopAtLevel=1",
|
117
|
+
"-Xverify:none",
|
118
|
+
"-jar",
|
119
|
+
testSelfrunFile.getAbsolutePath(),
|
120
|
+
"a1",
|
121
|
+
"a2"),
|
122
|
+
args);
|
116
123
|
}
|
117
124
|
|
118
125
|
@Test
|
119
126
|
public void testR1() throws Exception {
|
120
127
|
List<String> args = execute("-Rr1", "a1", "a2");
|
121
128
|
assertEquals(Arrays.asList(
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
129
|
+
"-XX:+AggressiveOpts",
|
130
|
+
"-XX:+TieredCompilation",
|
131
|
+
"-XX:TieredStopAtLevel=1",
|
132
|
+
"-Xverify:none",
|
133
|
+
"-jar",
|
134
|
+
testSelfrunFile.getAbsolutePath(),
|
135
|
+
"-Rr1",
|
136
|
+
"a1",
|
137
|
+
"a2"),
|
138
|
+
args);
|
132
139
|
}
|
133
140
|
|
134
141
|
@Test
|
135
142
|
public void testR2() throws Exception {
|
136
143
|
List<String> args = execute("\"-Rr1=v1\"", "\"-Rr2=v2\"", "a1", "a2");
|
137
144
|
assertEquals(Arrays.asList(
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
145
|
+
"-XX:+AggressiveOpts",
|
146
|
+
"-XX:+TieredCompilation",
|
147
|
+
"-XX:TieredStopAtLevel=1",
|
148
|
+
"-Xverify:none",
|
149
|
+
"-jar",
|
150
|
+
testSelfrunFile.getAbsolutePath(),
|
151
|
+
"-Rr1=v1",
|
152
|
+
"-Rr2=v2",
|
153
|
+
"a1",
|
154
|
+
"a2"),
|
155
|
+
args);
|
149
156
|
}
|
150
157
|
|
151
158
|
@Test
|
152
159
|
public void testRRun() throws Exception {
|
153
160
|
List<String> args = execute("-Rr1", "run", "a1");
|
154
161
|
assertEquals(Arrays.asList(
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
162
|
+
"-XX:+AggressiveOpts",
|
163
|
+
"-XX:+UseConcMarkSweepGC",
|
164
|
+
"-jar",
|
165
|
+
testSelfrunFile.getAbsolutePath(),
|
166
|
+
"-Rr1",
|
167
|
+
"run",
|
168
|
+
"a1"),
|
169
|
+
args);
|
163
170
|
}
|
164
171
|
|
165
172
|
@Test
|
166
173
|
public void testJ1() throws Exception {
|
167
174
|
List<String> args = execute("-J-Dj1", "a1", "a2");
|
168
175
|
assertEquals(Arrays.asList(
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
176
|
+
"-XX:+AggressiveOpts",
|
177
|
+
"-XX:+TieredCompilation",
|
178
|
+
"-XX:TieredStopAtLevel=1",
|
179
|
+
"-Xverify:none",
|
180
|
+
"-Dj1",
|
181
|
+
"-jar",
|
182
|
+
testSelfrunFile.getAbsolutePath(),
|
183
|
+
"a1",
|
184
|
+
"a2"),
|
185
|
+
args);
|
179
186
|
}
|
180
187
|
|
181
188
|
@Test
|
182
189
|
public void testJ2() throws Exception {
|
183
190
|
List<String> args = execute("\"-J-Dj1=v1\"", "\"-J-Dj2=v2\"", "a1", "a2");
|
184
191
|
assertEquals(Arrays.asList(
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
192
|
+
"-XX:+AggressiveOpts",
|
193
|
+
"-XX:+TieredCompilation",
|
194
|
+
"-XX:TieredStopAtLevel=1",
|
195
|
+
"-Xverify:none",
|
196
|
+
"-Dj1=v1",
|
197
|
+
"-Dj2=v2",
|
198
|
+
"-jar",
|
199
|
+
testSelfrunFile.getAbsolutePath(),
|
200
|
+
"a1",
|
201
|
+
"a2"),
|
202
|
+
args);
|
196
203
|
}
|
197
204
|
|
198
205
|
@Test
|
199
206
|
public void testJR() throws Exception {
|
200
207
|
List<String> args = execute("-Jj1", "-Rr1", "a1", "a2");
|
201
208
|
assertEquals(Arrays.asList(
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
209
|
+
"-XX:+AggressiveOpts",
|
210
|
+
"-XX:+TieredCompilation",
|
211
|
+
"-XX:TieredStopAtLevel=1",
|
212
|
+
"-Xverify:none",
|
213
|
+
"j1",
|
214
|
+
"-jar",
|
215
|
+
testSelfrunFile.getAbsolutePath(),
|
216
|
+
"-Rr1",
|
217
|
+
"a1",
|
218
|
+
"a2"),
|
219
|
+
args);
|
213
220
|
}
|
214
221
|
|
215
222
|
@Test
|
216
223
|
public void testJFile() throws Exception {
|
217
|
-
File javaArgsFile = new File(
|
218
|
-
FileSystem
|
219
|
-
Files.write(
|
224
|
+
File javaArgsFile = new File(testSelfrunFile.getParentFile(), "java_args.txt");
|
225
|
+
FileSystem fileSystem = FileSystems.getDefault();
|
226
|
+
Files.write(fileSystem.getPath(javaArgsFile.getAbsolutePath()),
|
227
|
+
"j1 j2 j3".getBytes(Charset.defaultCharset()),
|
228
|
+
StandardOpenOption.CREATE);
|
220
229
|
|
221
230
|
List<String> args = execute("-J", javaArgsFile.getAbsolutePath(), "a1", "a2");
|
222
231
|
assertEquals(Arrays.asList(
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
232
|
+
"-XX:+AggressiveOpts",
|
233
|
+
"-XX:+TieredCompilation",
|
234
|
+
"-XX:TieredStopAtLevel=1",
|
235
|
+
"-Xverify:none",
|
236
|
+
"j1",
|
237
|
+
"j2",
|
238
|
+
"j3",
|
239
|
+
"-jar",
|
240
|
+
testSelfrunFile.getAbsolutePath(),
|
241
|
+
"a1",
|
242
|
+
"a2"),
|
243
|
+
args);
|
235
244
|
}
|
236
245
|
|
237
246
|
private List<String> execute(String... arguments) throws Exception {
|
238
|
-
File temp = new File(
|
239
|
-
try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(temp),
|
240
|
-
|
247
|
+
File temp = new File(testSelfrunFile.getParentFile(), "call-" + testSelfrunFile.getName());
|
248
|
+
try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(temp),
|
249
|
+
Charset.defaultCharset()))) {
|
250
|
+
writer.write(testSelfrunFile.getAbsolutePath());
|
241
251
|
for (String argument : arguments) {
|
242
252
|
writer.write(" ");
|
243
253
|
writer.write(argument);
|
244
254
|
}
|
245
255
|
}
|
246
256
|
if (!temp.setExecutable(true)) {
|
247
|
-
|
257
|
+
throw new Exception("Cannot set the copied selfrun file executable..");
|
248
258
|
}
|
249
259
|
|
250
|
-
File argsFile = new File(
|
260
|
+
File argsFile = new File(testSelfrunFile.getParentFile(), "args.txt");
|
251
261
|
if (argsFile.exists()) {
|
252
262
|
if (!argsFile.delete()) {
|
253
|
-
|
263
|
+
throw new IOException("Cannot delete " + argsFile);
|
254
264
|
}
|
255
265
|
}
|
256
266
|
|
@@ -258,15 +268,17 @@ public class SelfrunTest {
|
|
258
268
|
int exitCode = process.waitFor();
|
259
269
|
if (exitCode != 0 || !argsFile.exists()) {
|
260
270
|
StringBuilder builder = new StringBuilder();
|
261
|
-
try (BufferedReader reader = new BufferedReader(new InputStreamReader(process.getErrorStream(),
|
271
|
+
try (BufferedReader reader = new BufferedReader(new InputStreamReader(process.getErrorStream(),
|
272
|
+
Charset.defaultCharset()))) {
|
262
273
|
builder.append(reader.readLine());
|
263
274
|
builder.append(System.getProperty("line.separator"));
|
264
275
|
}
|
265
276
|
throw new Exception(builder.toString());
|
266
277
|
}
|
267
278
|
|
268
|
-
FileSystem
|
269
|
-
List<String> args = Files.readAllLines(
|
279
|
+
FileSystem fileSystem = FileSystems.getDefault();
|
280
|
+
List<String> args = Files.readAllLines(fileSystem.getPath(argsFile.getAbsolutePath()),
|
281
|
+
Charset.defaultCharset());
|
270
282
|
return args;
|
271
283
|
}
|
272
284
|
|
@@ -275,7 +287,10 @@ public class SelfrunTest {
|
|
275
287
|
if (new File(folder, "embulk-cli").exists()) {
|
276
288
|
folder = new File(folder, "embulk-cli");
|
277
289
|
}
|
278
|
-
|
290
|
+
if (System.getProperty("file.separator").equals("\\")) {
|
291
|
+
return new File(new File(new File(new File(folder, "src"), "main"), "bat"), "selfrun.bat");
|
292
|
+
} else {
|
293
|
+
return new File(new File(new File(new File(folder, "src"), "main"), "sh"), "selfrun.sh");
|
294
|
+
}
|
279
295
|
}
|
280
|
-
|
281
296
|
}
|