about summary refs log tree commit diff
path: root/compiler/rustc_feature/src/tests.rs
diff options
context:
space:
mode:
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>2020-12-12 19:18:44 +0300
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>2020-12-12 19:18:44 +0300
commitec09616078e89deab5f97e578b3400b045c09575 (patch)
tree902dcbbdbb0f59b506f50ffe704645a8870d9f76 /compiler/rustc_feature/src/tests.rs
parent3f2088aa603d2cd3f43c20795872de9cd6ec7735 (diff)
downloadrust-ec09616078e89deab5f97e578b3400b045c09575.tar.gz
rust-ec09616078e89deab5f97e578b3400b045c09575.zip
tidy: Re-enable check for inline unit tests
Diffstat (limited to 'compiler/rustc_feature/src/tests.rs')
-rw-r--r--compiler/rustc_feature/src/tests.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/compiler/rustc_feature/src/tests.rs b/compiler/rustc_feature/src/tests.rs
new file mode 100644
index 00000000000..50433e44b13
--- /dev/null
+++ b/compiler/rustc_feature/src/tests.rs
@@ -0,0 +1,23 @@
+use super::UnstableFeatures;
+
+#[test]
+fn rustc_bootstrap_parsing() {
+    let is_bootstrap = |env, krate| {
+        std::env::set_var("RUSTC_BOOTSTRAP", env);
+        matches!(UnstableFeatures::from_environment(krate), UnstableFeatures::Cheat)
+    };
+    assert!(is_bootstrap("1", None));
+    assert!(is_bootstrap("1", Some("x")));
+    // RUSTC_BOOTSTRAP allows specifying a specific crate
+    assert!(is_bootstrap("x", Some("x")));
+    // RUSTC_BOOTSTRAP allows multiple comma-delimited crates
+    assert!(is_bootstrap("x,y,z", Some("x")));
+    assert!(is_bootstrap("x,y,z", Some("y")));
+    // Crate that aren't specified do not get unstable features
+    assert!(!is_bootstrap("x", Some("a")));
+    assert!(!is_bootstrap("x,y,z", Some("a")));
+    assert!(!is_bootstrap("x,y,z", None));
+
+    // this is technically a breaking change, but there are no stability guarantees for RUSTC_BOOTSTRAP
+    assert!(!is_bootstrap("0", None));
+}