logname may not produce a login name
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 45/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- ruby
- 領域
- testing-qa
調査の方向性
spec/ruby/library/etc/getlogin_spec.rb:22 から始め、GitHub Actions 環境の JRuby で失敗する Etc.getlogin の例を再現します。利用可能なログイン名取得コマンドと、issue に記載されている環境値を比較し、そのうえで制御端末のない環境を spec が処理できるようにします。コマンドが利用できない場合のフォールバックを維持したまま、JRuby で spec がパスすれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Running the specs on JRuby on Github Actions, we see the following message and failing spec:
...
logname: no login name
...
1)
Etc.getlogin returns the name associated with the current login activity FAILED
Expected "runner" == ""
to be truthy but was false
/home/runner/work/jruby/jruby/spec/ruby/library/etc/getlogin_spec.rb:22:in `block in <main>'
...
This can occur when logname is run without a controlling terminal. I'm unsure whether this GHA env is not setting up a tty, or if there's an issue launching the command in JRuby that prevents it inheriting the parent terminal, but it seems like id would be a more reliable command to use:
diff --git a/spec/ruby/library/etc/getlogin_spec.rb b/spec/ruby/library/etc/getlogin_spec.rb
index 7a4fd79ae2..f0dde84ccb 100644
--- a/spec/ruby/library/etc/getlogin_spec.rb
+++ b/spec/ruby/library/etc/getlogin_spec.rb
@@ -18,11 +18,13 @@ describe "Etc.getlogin" do
else
# Etc.getlogin returns the same result of logname(2)
# if it returns non NULL
- if system("which logname", out: File::NULL, err: File::NULL)
+ if system("which id", out: File::NULL, err: File::NULL)
+ Etc.getlogin.should == `id -un`.chomp
+ elsif system("which logname", out: File::NULL, err: File::NULL)
+ # fallback to `logname` command since `id` is not available
Etc.getlogin.should == `logname`.chomp
else
- # fallback to `id` command since `logname` is not available
- Etc.getlogin.should == `id -un`.chomp
+ Etc.getlogin.should == ENV['LOGNAME']
end
end
else
However I think we are also stacking too many conditions here. I'm unsure of the "best" way to get the current login, but clearly logname has issues that make it undesirable.
FWIW some forums suggest logname -t which will ensure a tty is created, but this flag is not present on BSD-likes.
- 主要言語
- Ruby
- スター
- 622
- フォーク
- 402
- 平均マージ
- 14時間 51分
- マージ済み PR(30日)
- 6
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
ruby/spec のほかの issue
-
難易度 3/5 1〜2日 初心者へのやさしさ 52/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 38/100
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 38/100
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
palladius/rails8-app-on-gcp#145 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
rubocop/rubocop-rspec#2236 ·
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
riscv/riscv-unified-db#2624 · リアクション 1 件 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100