Skip to content

Commit edb6a93

Browse files
committed
more debug
1 parent fdaa7f7 commit edb6a93

File tree

1 file changed

+4
-160
lines changed

1 file changed

+4
-160
lines changed

spec/acceptance/user_spec.rb

Lines changed: 4 additions & 160 deletions
Original file line numberDiff line numberDiff line change
@@ -3,171 +3,12 @@
33
require 'spec_helper_acceptance'
44

55
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-
1666
it 'can remove itself after the user was deleted' do
1677
rm_user('rustup_test')
1688

1699
puts "/etc/skel"
17010
puts Dir.entries("/etc/skel").sort rescue puts "no /etc/skel"
11+
puts "--------"
17112

17213
puts "default cargo home"
17314
puts "run 1"
@@ -187,7 +28,10 @@
18728
#before => Rustup['rustup_test'],
18829
}
18930
END
31+
32+
puts "/home/rustup_test"
19033
puts Dir.entries("/home/rustup_test").sort rescue puts "no /home/rustup_test"
34+
puts "--------"
19135
puts "run 1a"
19236

19337
puts apply_manifest(<<~'END', catch_failures: true, prefix_command: 'RUSTUP_TRACE=1 ').stderr

0 commit comments

Comments
 (0)