File: 0005-tests-disable-self-update-tests.patch

package info (click to toggle)
rustup 1.27.1-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,588 kB
  • sloc: sh: 856; python: 233; javascript: 183; makefile: 27
file content (143 lines) | stat: -rw-r--r-- 4,902 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
From: liushuyu <liushuyu011@gmail.com>
Date: Tue, 12 Sep 2023 17:10:31 -0600
Subject: [PATCH 5/7] tests: disable self-update tests
Forwarded: no

---
 src/test.rs               | 13 +++++++++++++
 src/test/mock/clitools.rs |  8 +++++++-
 tests/suite/cli_exact.rs  |  2 ++
 tests/suite/cli_paths.rs  |  3 +++
 tests/suite/cli_v2.rs     |  3 ++-
 5 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/src/test.rs b/src/test.rs
index 617b765..b537bf3 100644
--- a/src/test.rs
+++ b/src/test.rs
@@ -175,6 +175,19 @@ macro_rules! for_host {
     };
 }
 
+#[macro_export]
+macro_rules! get_output_trailer {
+    () => {
+        if cfg!(feature = "no-self-update") {
+            "info: self-update is disabled for this build of rustup
+info: any updates to rustup will need to be fetched with your system package manager
+"
+        } else {
+            "\n"
+        }
+    };
+}
+
 #[derive(Clone, Debug)]
 /// The smallest form of test isolation: an isolated RUSTUP_HOME, for codepaths
 /// that read and write config files but do not invoke processes, download data
diff --git a/src/test/mock/clitools.rs b/src/test/mock/clitools.rs
index efa071e..328aaa7 100644
--- a/src/test/mock/clitools.rs
+++ b/src/test/mock/clitools.rs
@@ -24,6 +24,7 @@ use crate::test as rustup_test;
 use crate::test::const_dist_dir;
 use crate::test::this_host_triple;
 use crate::utils::{raw, utils};
+use crate::get_output_trailer;
 
 use super::{
     dist::{
@@ -335,6 +336,7 @@ fn create_local_update_server(self_dist: &Path, exedir: &Path, version: &str) ->
     root_url
 }
 
+#[cfg(not(feature = "no-self-update"))]
 pub fn self_update_setup(f: &dyn Fn(&mut Config, &Path), version: &str) {
     test(Scenario::SimpleV2, &|config| {
         // Create a mock self-update server
@@ -593,11 +595,15 @@ impl Config {
     #[track_caller]
     pub fn expect_ok_ex(&mut self, args: &[&str], stdout: &str, stderr: &str) {
         let out = self.run(args[0], &args[1..], &[]);
+        let mut stderr = stderr.to_string();
+        if out.stderr != stderr {
+            stderr = format!("{}\n{}", stderr.trim_end(), get_output_trailer!());
+        }
         if !out.ok || out.stdout != stdout || out.stderr != stderr {
             print_command(args, &out);
             println!("expected.ok: true");
             print_indented("expected.stdout", stdout);
-            print_indented("expected.stderr", stderr);
+            print_indented("expected.stderr", &stderr);
             dbg!(out.stdout == stdout);
             dbg!(out.stderr == stderr);
             panic!();
diff --git a/tests/suite/cli_exact.rs b/tests/suite/cli_exact.rs
index fc92c22..51c6435 100644
--- a/tests/suite/cli_exact.rs
+++ b/tests/suite/cli_exact.rs
@@ -45,6 +45,7 @@ info: default toolchain set to 'nightly-{0}'
 }
 
 #[test]
+#[cfg(not(feature = "no-self-update"))]
 fn update_once_and_check_self_update() {
     let test_version = "2.0.0";
     test(&|config| {
@@ -86,6 +87,7 @@ info: installing component 'rustc'
 }
 
 #[test]
+#[cfg(not(feature = "no-self-update"))]
 fn update_once_and_self_update() {
     let test_version = "2.0.0";
 
diff --git a/tests/suite/cli_paths.rs b/tests/suite/cli_paths.rs
index 5911212..896387e 100644
--- a/tests/suite/cli_paths.rs
+++ b/tests/suite/cli_paths.rs
@@ -239,6 +239,7 @@ export PATH="$HOME/apple/bin"
     }
 
     #[test]
+    #[cfg(not(feature = "no-self-update"))]
     fn uninstall_removes_source_from_rcs() {
         clitools::test(Scenario::Empty, &|config| {
             let rcs: Vec<PathBuf> = [
@@ -305,6 +306,7 @@ export PATH="$HOME/apple/bin"
     }
 
     #[test]
+    #[cfg(not(feature = "no-self-update"))]
     fn uninstall_cleans_up_legacy_paths() {
         clitools::test(Scenario::Empty, &|config| {
             // Install first, then overwrite.
@@ -347,6 +349,7 @@ export PATH="$HOME/apple/bin"
     // In the default case we want to write $HOME/.cargo/bin as the path,
     // not the full path.
     #[test]
+    #[cfg(not(feature = "no-self-update"))]
     fn when_cargo_home_is_the_default_write_path_specially() {
         clitools::test(Scenario::Empty, &|config| {
             // Override the test harness so that cargo home looks like
diff --git a/tests/suite/cli_v2.rs b/tests/suite/cli_v2.rs
index 81ba41e..5d1dcf9 100644
--- a/tests/suite/cli_v2.rs
+++ b/tests/suite/cli_v2.rs
@@ -1300,6 +1300,7 @@ fn install_with_component_and_target() {
 }
 
 #[test]
+#[cfg(not(feature = "no-self-update"))]
 fn test_warn_if_complete_profile_is_used() {
     setup(&|config| {
         config.expect_ok(&["rustup", "set", "auto-self-update", "enable"]);
@@ -1312,7 +1313,7 @@ fn test_warn_if_complete_profile_is_used() {
                 "complete",
                 "stable",
             ],
-            "warning: downloading with complete profile",
+            "warning: downloading with complete profile isn't recommended",
         );
     });
 }