Skip to content

Commit 13687ca

Browse files
mchernyavskyyopox
authored andcommitted
T: Add a test for redirect input
1 parent 9388d24 commit 13687ca

File tree

1 file changed

+42
-1
lines changed

1 file changed

+42
-1
lines changed

src/test/kotlin/org/rustSlowTests/cargo/runconfig/RunConfigurationTest.kt

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ class RunConfigurationTest : RunConfigurationTestBase() {
132132
check("""{ "type": "test", "event": "started", "name": "tests::bar" }""" in result.stdout)
133133
}
134134

135-
fun `test redirect input`() {
135+
fun `test redirect input (absolute path)`() {
136136
fileTree {
137137
toml("Cargo.toml", """
138138
[package]
@@ -173,4 +173,45 @@ class RunConfigurationTest : RunConfigurationTestBase() {
173173
check("2. bbb" in stdout)
174174
check("3. ccc" !in stdout)
175175
}
176+
177+
fun `test redirect input (relative path)`() {
178+
fileTree {
179+
toml("Cargo.toml", """
180+
[package]
181+
name = "hello"
182+
version = "0.1.0"
183+
authors = []
184+
""")
185+
186+
dir("src") {
187+
rust("main.rs", """
188+
use std::io::{self, BufRead};
189+
190+
fn main() {
191+
let stdin = io::stdin();
192+
let mut iter = stdin.lock().lines();
193+
println!("{}", iter.next().unwrap().unwrap());
194+
println!("{}", iter.next().unwrap().unwrap()); }
195+
""")
196+
}
197+
198+
file("in.txt", """
199+
1. aaa
200+
2. bbb
201+
3. ccc
202+
""")
203+
}.create()
204+
205+
val configuration = createConfiguration()
206+
.apply {
207+
isRedirectInput = true
208+
redirectInputPath = "in.txt"
209+
}
210+
211+
val result = executeAndGetOutput(configuration)
212+
val stdout = result.stdout
213+
check("1. aaa" in stdout)
214+
check("2. bbb" in stdout)
215+
check("3. ccc" !in stdout)
216+
}
176217
}

0 commit comments

Comments
 (0)