|
3 | 3 | require 'spec_helper_acceptance' |
4 | 4 |
|
5 | 5 | describe 'Per-user rustup management' do |
6 | | - context 'supports installing without toolchain' do |
7 | | - it do |
8 | | - idempotent_apply(<<~'END') |
9 | | - user { 'user': |
10 | | - ensure => present, |
11 | | - managehome => true, |
12 | | - shell => '/bin/bash', |
13 | | - } |
14 | | - rustup { 'user': } |
15 | | - END |
16 | | - end |
17 | | - |
18 | | - describe file('/home/user/.rustup') do |
19 | | - it { is_expected.to be_directory } |
20 | | - it { is_expected.to be_owned_by 'user' } |
21 | | - end |
22 | | - |
23 | | - describe file('/home/user/.cargo/bin/rustup') do |
24 | | - it { is_expected.to be_file } |
25 | | - it { is_expected.to be_executable } |
26 | | - it { is_expected.to be_owned_by 'user' } |
27 | | - end |
28 | | - |
29 | | - describe file('/home/user/.bashrc') do |
30 | | - it { is_expected.to be_file } |
31 | | - its(:content) { is_expected.to match %r{^\. "\$HOME/\.cargo/env"$} } |
32 | | - end |
33 | | - |
34 | | - describe file('/home/user/.profile') do |
35 | | - it { is_expected.to be_file } |
36 | | - its(:content) { is_expected.to match %r{^\. "\$HOME/\.cargo/env"$} } |
37 | | - end |
38 | | - |
39 | | - describe command_as_user("echo '$PATH'") do |
40 | | - its(:stdout) do |
41 | | - is_expected.to match %r{(\A|:)/home/user/\.cargo/bin:} |
42 | | - is_expected.not_to match %r{/opt/rust/cargo/bin} |
43 | | - end |
44 | | - its(:stderr) { is_expected.to eq '' } |
45 | | - its(:exit_status) { is_expected.to eq 0 } |
46 | | - end |
47 | | - |
48 | | - describe command_as_user('rustup toolchain list') do |
49 | | - its(:stdout) { is_expected.to match %r{^no installed toolchains$} } |
50 | | - its(:stderr) { is_expected.to eq '' } |
51 | | - its(:exit_status) { is_expected.to eq 0 } |
52 | | - end |
53 | | - |
54 | | - describe command_as_user('rm -rf hello-world') do |
55 | | - its(:exit_status) { is_expected.to eq 0 } |
56 | | - end |
57 | | - |
58 | | - # FIXME: this test will fail if there is any present rustup installation. As |
59 | | - # long as the tests are run in order (sigh), they should clean themselves |
60 | | - # up. Unfortunately, there doesn’t seem to be a way to just reset the VM. |
61 | | - describe command_as_user('cargo init hello-world --bin --quiet') do |
62 | | - its(:stderr) do |
63 | | - is_expected.to match( |
64 | | - %r{error: rustup could not choose a version of cargo to run}, |
65 | | - ) |
66 | | - end |
67 | | - its(:exit_status) { is_expected.to be > 0 } |
68 | | - end |
69 | | - end |
70 | | - |
71 | | - context 'fails with uninstalled default_toolchain' do |
72 | | - it do |
73 | | - apply_manifest(<<~'PUPPET', expect_failures: true) |
74 | | - rustup { 'user': |
75 | | - purge_toolchains => true, |
76 | | - toolchains => ['nightly', 'stable'], |
77 | | - targets => ['default nightly', 'default stable'], |
78 | | - default_toolchain => 'beta', |
79 | | - } |
80 | | - PUPPET |
81 | | - end |
82 | | - end |
83 | | - |
84 | | - context 'supports installing non-host toolchain' do |
85 | | - target = 'x86_64-pc-windows-gnu' |
86 | | - toolchain = "stable-#{target}" |
87 | | - |
88 | | - it do |
89 | | - # Note that the quotes here are within the END block. |
90 | | - idempotent_apply(<<~END) |
91 | | - rustup { 'user': } |
92 | | - rustup::toolchain { 'user: #{toolchain}': } |
93 | | - END |
94 | | - end |
95 | | - |
96 | | - command = "rustup target list --toolchain #{toolchain}" |
97 | | - describe command_as_user(command) do |
98 | | - its(:stdout) do |
99 | | - is_expected.to match(%r{^#{target} \(installed\)$}) |
100 | | - end |
101 | | - its(:stderr) { is_expected.to eq '' } |
102 | | - its(:exit_status) { is_expected.to eq 0 } |
103 | | - end |
104 | | - end |
105 | | - |
106 | | - context 'supports multi-resource uninstall for a real user' do |
107 | | - it do |
108 | | - idempotent_apply(<<~'END') |
109 | | - rustup { 'user': |
110 | | - ensure => absent, |
111 | | - } |
112 | | - rustup::toolchain { 'user: stable': |
113 | | - ensure => absent, |
114 | | - } |
115 | | - rustup::target { 'user: wasm32-unknown-unknown stable': |
116 | | - ensure => absent, |
117 | | - } |
118 | | - END |
119 | | - end |
120 | | - |
121 | | - describe file('/home/user/.rustup') do |
122 | | - it { is_expected.not_to exist } |
123 | | - end |
124 | | - |
125 | | - describe file('/home/user/.cargo') do |
126 | | - it { is_expected.not_to exist } |
127 | | - end |
128 | | - |
129 | | - describe file('/home/user/.bashrc') do |
130 | | - it { is_expected.to be_file } |
131 | | - its(:content) { is_expected.not_to match %r{^\. "\$HOME/\.cargo/env"$} } |
132 | | - end |
133 | | - |
134 | | - describe file('/home/user/.profile') do |
135 | | - it { is_expected.to be_file } |
136 | | - its(:content) { is_expected.not_to match %r{^\. "\$HOME/\.cargo/env"$} } |
137 | | - end |
138 | | - |
139 | | - describe command_as_user("echo '$PATH'") do |
140 | | - its(:stdout) do |
141 | | - is_expected.not_to match %r{(\A|:)/home/user/\.cargo/bin(:|\Z)} |
142 | | - end |
143 | | - its(:stderr) { is_expected.to eq '' } |
144 | | - its(:exit_status) { is_expected.to eq 0 } |
145 | | - end |
146 | | - end |
147 | | - |
148 | | - it 'supports ensure=>absent with non-existant user' do |
149 | | - expect(user('non_existant_user')).not_to exist |
150 | | - |
151 | | - idempotent_apply(<<~'END') |
152 | | - rustup { 'non_existant_user': |
153 | | - ensure => absent, |
154 | | - } |
155 | | - rustup::toolchain { 'non_existant_user: stable': |
156 | | - ensure => absent, |
157 | | - } |
158 | | - rustup::target { 'non_existant_user: wasm32-unknown-unknown stable': |
159 | | - ensure => absent, |
160 | | - } |
161 | | - END |
162 | | - |
163 | | - expect(user('non_existant_user')).not_to exist |
164 | | - end |
165 | | - |
166 | 6 | it 'can remove itself after the user was deleted' do |
167 | 7 | rm_user('rustup_test') |
168 | 8 |
|
169 | 9 | puts "/etc/skel" |
170 | 10 | puts Dir.entries("/etc/skel").sort rescue puts "no /etc/skel" |
| 11 | + puts "--------" |
171 | 12 |
|
172 | 13 | puts "default cargo home" |
173 | 14 | puts "run 1" |
|
187 | 28 | #before => Rustup['rustup_test'], |
188 | 29 | } |
189 | 30 | END |
| 31 | + |
| 32 | + puts "/home/rustup_test" |
190 | 33 | puts Dir.entries("/home/rustup_test").sort rescue puts "no /home/rustup_test" |
| 34 | + puts "--------" |
191 | 35 | puts "run 1a" |
192 | 36 |
|
193 | 37 | puts apply_manifest(<<~'END', catch_failures: true, prefix_command: 'RUSTUP_TRACE=1 ').stderr |
|
0 commit comments