Skip to content

Commit d2da6ed

Browse files
committed
Add a test run on Windows with non-admin user and disabled developer mode
This way we can ensure that rubygems runs on a normal user account with symlinks disabled. That is the default on an interactive Windows.
1 parent a1b3b73 commit d2da6ed

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

.github/workflows/rubygems.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,14 @@ jobs:
3737
- ruby: { name: truffleruby, value: truffleruby-24.2.1 }
3838
os: { name: Ubuntu, value: ubuntu-24.04 }
3939

40+
- ruby: { name: "no symlinks", value: 4.0.0 }
41+
os: { name: Windows, value: windows-2025 }
42+
symlink: off
43+
4044
steps:
45+
- name: disable development mode on Windows
46+
run: powershell -c "Set-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock -Name AllowDevelopmentWithoutDevLicense -Value 0"
47+
if: matrix.symlink == 'off'
4148
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
4249
with:
4350
persist-credentials: false
@@ -48,9 +55,14 @@ jobs:
4855
bundler: none
4956
- name: Install Dependencies
5057
run: bin/rake setup
58+
- name: Run Test with non-Admin user
59+
run: |
60+
gem inst win32-process --no-doc --conservative
61+
ruby bin/windows_run_as_user ruby -S rake test
62+
if: matrix.symlink == 'off'
5163
- name: Run Test
5264
run: bin/rake test
53-
if: matrix.ruby.name != 'truffleruby' && matrix.ruby.name != 'jruby'
65+
if: matrix.ruby.name != 'truffleruby' && matrix.ruby.name != 'jruby' && matrix.symlink != 'off'
5466
- name: Run Test isolatedly
5567
run: bin/rake test:isolated
5668
if: matrix.ruby.name == '3.4' && matrix.os.name != 'Windows'

bin/windows_run_as_user

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
require "win32/process"
2+
require "rbconfig"
3+
4+
TESTUSER = "testuser"
5+
6+
system("net user #{TESTUSER} /del 2>NUL")
7+
system("net user #{TESTUSER} \"Password123+\" /add") || raise
8+
system("icacls . /grant #{TESTUSER}:(OI)(CI)(IO)(F)")
9+
10+
stdout_read, stdout_write = IO.pipe
11+
cmd = ARGV.join(" ")
12+
env = {
13+
"TMP" => "#{Dir.pwd}/tmp",
14+
"TEMP" => "#{Dir.pwd}/tmp"
15+
}
16+
pinfo = Process.create command_line: cmd,
17+
with_logon: TESTUSER,
18+
password: "Password123+",
19+
cwd: Dir.pwd,
20+
environment: ENV.to_h.merge(env).map{|k,v| "#{k}=#{v}" },
21+
startup_info: { stdout: stdout_write, stderr: stdout_write }
22+
23+
stdout_write.close
24+
out = stdout_read.read
25+
puts out
26+
27+
# Wait for process to terminate
28+
sleep 0.1 while !(ecode=Process.get_exitcode(pinfo.process_id))
29+
30+
exit ecode

0 commit comments

Comments
 (0)