aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2021-03-12 15:51:26 -0500
committerJesse Luehrs <doy@tozt.net>2021-03-12 15:51:26 -0500
commit1aa54fb6b45e8eea4604f8c8acaecb3bb9086fb4 (patch)
tree68a3d002da070d7dafbca7c2e73e6f307b1007c1 /tests
parenteb3f6dbccfc2f1c87ec3c38c78abc3337ceb3ccb (diff)
downloadtextmode-1aa54fb6b45e8eea4604f8c8acaecb3bb9086fb4.tar.gz
textmode-1aa54fb6b45e8eea4604f8c8acaecb3bb9086fb4.zip
add another test
Diffstat (limited to 'tests')
-rw-r--r--tests/basic.rs21
-rw-r--r--tests/fixtures/bin/Cargo.toml6
l---------tests/fixtures/bin/src/bin/async.rs1
-rw-r--r--tests/fixtures/mod.rs3
4 files changed, 29 insertions, 2 deletions
diff --git a/tests/basic.rs b/tests/basic.rs
index 71ed857..3b52bc2 100644
--- a/tests/basic.rs
+++ b/tests/basic.rs
@@ -5,7 +5,26 @@ mod fixtures;
#[test]
fn test_basic() {
- fixtures::run_fixture("basic", true, |pty| {
+ fixtures::run_fixture("basic", "", true, |pty| {
+ pty.write_all(b"a").unwrap();
+ assert_eq!(fixtures::read(pty), b"\x1b[6;6Hfoo");
+
+ pty.write_all(b"a").unwrap();
+ assert!(!fixtures::read_ready(pty.as_raw_fd()));
+
+ pty.write_all(b"a").unwrap();
+ assert_eq!(
+ fixtures::read(pty),
+ b"\x1b[9;9H\x1b[32mbar\x1b[12;12H\x1b[mbaz"
+ );
+
+ pty.write_all(b"a").unwrap();
+ });
+}
+
+#[test]
+fn test_async() {
+ fixtures::run_fixture("async", "async", true, |pty| {
pty.write_all(b"a").unwrap();
assert_eq!(fixtures::read(pty), b"\x1b[6;6Hfoo");
diff --git a/tests/fixtures/bin/Cargo.toml b/tests/fixtures/bin/Cargo.toml
index 83fff5e..cac6fe1 100644
--- a/tests/fixtures/bin/Cargo.toml
+++ b/tests/fixtures/bin/Cargo.toml
@@ -7,3 +7,9 @@ edition = "2018"
[dependencies]
textmode = { path = "../../.." }
vt100 = "*"
+
+smol = { version = "*", optional = true }
+
+[features]
+default = []
+async = ["textmode/async", "smol"]
diff --git a/tests/fixtures/bin/src/bin/async.rs b/tests/fixtures/bin/src/bin/async.rs
new file mode 120000
index 0000000..ff890ad
--- /dev/null
+++ b/tests/fixtures/bin/src/bin/async.rs
@@ -0,0 +1 @@
+../../../../../examples/async.rs \ No newline at end of file
diff --git a/tests/fixtures/mod.rs b/tests/fixtures/mod.rs
index 766886c..61d9e04 100644
--- a/tests/fixtures/mod.rs
+++ b/tests/fixtures/mod.rs
@@ -2,7 +2,7 @@ use pty_process::Command as _;
use std::io::Read as _;
use std::os::unix::io::AsRawFd as _;
-pub fn run_fixture<F>(name: &str, screenguard: bool, f: F)
+pub fn run_fixture<F>(name: &str, features: &str, screenguard: bool, f: F)
where
F: FnOnce(&mut std::fs::File),
{
@@ -13,6 +13,7 @@ where
.current_target()
.manifest_path("tests/fixtures/bin/Cargo.toml")
.target_dir(temp.path())
+ .features(features)
.run()
.unwrap();
let mut cmd = run.command();