Skip to content

Commit 75c3468

Browse files
committed
✨ v2.3.6-alpha.1
1 parent 4298944 commit 75c3468

File tree

5 files changed

+94
-25
lines changed

5 files changed

+94
-25
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "whitespace-sifter"
3-
version = "2.3.5"
3+
version = "2.3.6-alpha.1"
44
edition = "2021"
55
authors = ["JumperBot_"]
66
description = "Sift duplicate whitespaces away!"

src/compliance_test.rs

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
use std::process::{Command, Output};
2+
3+
const VERSIONS: [&str; 7] = [
4+
"2.3.5", "2.3.4", "2.3.3", "2.3.2", "2.3.1", "2.2.0", "2.1.0",
5+
];
6+
7+
#[test]
8+
fn test_old_versions() {
9+
let cargo_new: Output = Command::new("cargo")
10+
.args(["new", "--lib", "compliance_tester_temp"])
11+
.output()
12+
.expect("Failed to test old versions");
13+
14+
assert!(cargo_new.status.success());
15+
16+
std::fs::write(
17+
"compliance_tester_temp/src/lib.rs",
18+
include_str!("tests.rs")
19+
.replace(
20+
"use crate::WhitespaceSifter;",
21+
"#[allow(unused_imports)] use whitespace_sifter::WhitespaceSifter;",
22+
)
23+
.as_bytes(),
24+
)
25+
.expect("Failed to inject test code");
26+
27+
for ver in VERSIONS.iter().rev() {
28+
std::fs::write(
29+
"compliance_tester_temp/Cargo.toml",
30+
&format!(
31+
"
32+
[package]
33+
name = \"compliance_tester_temp\"
34+
version = \"0.1.0\"
35+
edition = \"2021\"
36+
37+
[dependencies]
38+
whitespace-sifter = \"={ver}\"
39+
"
40+
),
41+
)
42+
.expect("Failed to inject Cargo.toml base");
43+
44+
let cargo_test: Output = Command::new("cargo")
45+
.arg("test")
46+
.current_dir(
47+
std::env::current_dir()
48+
.expect("Failed to get current directory")
49+
.join("compliance_tester_temp"),
50+
)
51+
.output()
52+
.expect("Failed to run cargo test");
53+
54+
assert!(!String::from_utf8_lossy(&cargo_test.stdout).contains("FAIL"));
55+
assert!(!String::from_utf8_lossy(&cargo_test.stderr).contains("FAIL"));
56+
}
57+
58+
std::fs::remove_dir_all(
59+
std::env::current_dir()
60+
.expect("Failed to get current directory")
61+
.join("compliance_tester_temp"),
62+
)
63+
.expect("Failed to remove compliance_tester_temp directory");
64+
}

src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,9 @@ pub(crate) fn sift_trim_end(out: &mut Vec<u8>, is_last_whitespace: bool) {
116116

117117
#[cfg(test)]
118118
mod tests;
119+
120+
#[cfg(test)]
121+
mod msrv_test;
122+
123+
#[cfg(test)]
124+
mod compliance_test;

src/msrv_test.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
use std::process::{Command, Output};
2+
3+
#[test]
4+
fn verify_msrv() {
5+
let verify_out: Output = Command::new("cargo")
6+
.args(["msrv", "verify"])
7+
.output()
8+
.expect("Failed to verify MSRV");
9+
10+
assert!(verify_out.status.success());
11+
12+
let cmp: &str = "OK";
13+
assert!(verify_out
14+
.stdout
15+
.windows(cmp.len())
16+
.any(|window| window == cmp.as_bytes()));
17+
18+
let cmp: &str = "Is compatible";
19+
assert!(verify_out
20+
.stdout
21+
.windows(cmp.len())
22+
.any(|window| window == cmp.as_bytes()));
23+
}

src/tests.rs

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
use crate::WhitespaceSifter;
22

3-
use std::process::{Command, Output};
4-
53
#[test]
64
fn test_unicode_compatibility() {
75
let input: String = " a1❤️🌐🚀1a ".to_owned();
@@ -68,25 +66,3 @@ fn test_docs() {
6866
"1..\n2..\n3..\n4..\r\n5.."
6967
);
7068
}
71-
72-
#[test]
73-
fn verify_msrv() {
74-
let verify_out: Output = Command::new("cargo")
75-
.args(["msrv", "verify"])
76-
.output()
77-
.expect("Failed to verify MSRV");
78-
79-
assert!(verify_out.status.success());
80-
81-
let cmp: &str = "OK";
82-
assert!(verify_out
83-
.stdout
84-
.windows(cmp.len())
85-
.any(|window| window == cmp.as_bytes()));
86-
87-
let cmp: &str = "Is compatible";
88-
assert!(verify_out
89-
.stdout
90-
.windows(cmp.len())
91-
.any(|window| window == cmp.as_bytes()));
92-
}

0 commit comments

Comments
 (0)