Commit graph

22 commits

Author SHA1 Message Date
Sorah Fukumori
cd41177815 [ruby/irb] test_recovery_sigint: Ensure precondition is met
(https://github.com/ruby/irb/pull/829)

* test_recovery_sigint: Ensure precondition is met

test_recovery_sigint depends on its process has SIG_DEF sigaction for
SIGINT. When its parent process set SIG_IGN which inherits to children,
then this test fails. This patch ensures this precondition met
regardless of inherited sigaction from its parent.

* Add test for restoration of other SIGINT handlers

Add another variant of test_recovery_sigint to ensure IRB to preserve
existing SIGINT handler other than SIG_DEF.

77ee59d026
2024-01-01 10:58:35 +00:00
Stan Lo
2793a30b69 [ruby/irb] Warn users about errors in loading RC files
(https://github.com/ruby/irb/pull/817)

1. Because `IRB.rc_file` always generates an rc file name, even if the
   file doesn't exist, we should check the file exists before trying to
   load it.
2. If any type of errors occur while loading the rc file, we should
   warn the user about it.

37ffdc6b19
2023-12-20 19:11:01 +09:00
ima1zumi
7164715666 [ruby/irb] Enable Setting Completer Type through IRB_COMPLETOR
(https://github.com/ruby/irb/pull/771)

I propose introducing the capability to set the IRB completion kinds via an environment variable, specifically `IRB_COMPLETOR=type`.
This feature aims to enhance the Rails console experience by allowing Rails users to specify their preferred completion more conveniently.

Currently, when using the Rails console, there's no straightforward way to globally set the type completion across a Rails application repository.
It's possible to configure this setting by placing a `.irbrc` file at the project root. However, using a .irbrc file is not ideal as it allows for broad configurations and can potentially affect the production environment.
My suggestion focuses on allowing users to set the completion to 'type' in a minimal.

This enhancement would be particularly beneficial for teams writing RBS in their Rails applications.
This type completer, integrated with RBS, would enhance completion accuracy, improving the Rails console experience.

032f6da25f
2023-11-21 00:04:41 +00:00
tomoya ishida
c4efd17061 [ruby/irb] Add command line option to select which completor to use
(https://github.com/ruby/irb/pull/754)

* Add command line option to select which completor to use

* Add test for completor argv

1dec2708c9
2023-11-09 13:15:26 +00:00
Stan Lo
91b106fe4b [ruby/irb] Stanardise test class names with Test postfix instead
of prefix
(https://github.com/ruby/irb/pull/603)

359cb28def
2023-06-13 11:02:26 +00:00
Stan Lo
9aa18f61f2 [ruby/irb] Allow disabling autocompletion with
`IRB_USE_AUTOCOMPLETE=false`
(https://github.com/ruby/irb/pull/469)

* Allow using IRB_USE_AUTOCOMPLETE=false to disable autocompletion

Currently, the only 2 ways to disable autocompletion are:

1. Create `.irbrc` and set `IRB.conf[:USE_AUTOCOMPLETE] = false`
2. Add the `--noautocomplete` flag when using the `irb` executable

Both of them are less convenient than setting a env var and are
lesser known to devs.

And given the number of problems the autocompletion has (see #445), I
think we should allow disabling it with a simple `IRB_USE_AUTOCOMPLETE=false`.

* Mention some env var configs in the README
2022-12-06 00:53:32 +00:00
Stan Lo
a923203811 [ruby/irb] Provide a base test class and let tests restore encodings
conveniently
(https://github.com/ruby/irb/pull/429)

* Create a base TestIRB::TestCase class

* Save/restore encodings for tests that initializes InputMethod classes

Because `RelineInputMethod#initializes` calls `set_encoding`, which
changes stdio/out/err and Encoding's default encoding values, we need to
make sure any test that directly or indirectly (e.g. through Context)
initializes `RelineInputMethod` restores encodings.

`ReadlineInputMethod` also changes encodings but currently no tests
cover it.

* Remove unnecessary TestHelper module

Since we now have a base TestCase, without_rdoc can just live there.

c2874ec121
2022-11-03 22:13:11 +00:00
Nobuyoshi Nakada
4021c6565f [ruby/irb] Do not make non-existent XDG directory on start
(https://github.com/ruby/irb/pull/357)


298b134792
2022-10-28 09:36:28 +00:00
Nobuyoshi Nakada
56c97a6621 [ruby/irb] Update regarding NO_COLOR value
https://no-color.org has been updated (jcs/no_color#83):

> Command-line software which adds ANSI color to its output by default
should check for a `NO_COLOR` environment variable that, when present
and **not an empty string** (regardless of its value), prevents the
addition of ANSI color.

46e0f7e370

Co-authored-by: Stan Lo <stan001212@gmail.com>
2022-10-28 09:30:24 +00:00
Jeremy Evans
b07db96744 [ruby/irb] Support --noscript option to not use first non-option argument as script
Also add --script option to turn the option back on.

Previously there wasn't a way to get an interactive IRB session
and access arguments provided on the command line.

Additionally, handle `-` as script as stdin. In Unix-like tools, `-`
means to take standard input instead of a file.  This doesn't
result in exactly the same output for:

```
echo 'p ARGV' > args.rb; irb args.rb a b c
```

and

```
echo 'p ARGV' | irb - a b c
```

Due to how irb handles whether stdin is a tty.

However, this change allows use of `-` as a argument, instead of
giving an unrecognized switch error. This required some small
changes to context.rb (to handle `-` as standard input) and
input-method.rb (to have FileInputMethod accept IO arguments in
addition to strings).

Implements [Feature #15371]

4192683ba2
2022-09-17 02:25:26 +09:00
Yusuke Endoh
56119c5245 Skip TestIRB::TestInit#test_recovery_sigint on Solaris
The test randomly gets stuck on Solaris:

20211105T060014Z.fail.html.gz
```
  1) Error:
TestIRB::TestInit#test_recovery_sigint:
Timeout::Error: execution of assert_in_out_err expired timeout (100.0 sec)
pid 3195 killed by SIGTERM (signal 15)
| Switch to inspect mode.
| exit
|
```

I investigated the issue but I couldn't figure it out.
This random failure is noisy, which makes it difficult to track the CI.
So I skip the test on Soalris. Contribution is welcome.
2021-11-05 20:03:11 +09:00
aycabta
f57968e329 Set USE_COLORIZE to the default value in a test 2021-05-24 12:13:46 +09:00
jethrodaniel
d06d4560a1 [ruby/irb] update test/irb/test_init.rb to avoid useless eval
Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>

2dfdc031ec
2021-05-24 11:56:05 +09:00
Mark Delk
b8ffb1c46f [ruby/irb] respect NO_COLOR environment variable
When `NO_COLOR` is set to any non-nil value, output is not colorized.

See https://no-color.org/

401d0916fe
2021-05-24 11:55:58 +09:00
Nobuyoshi Nakada
5219b4ddb4 [ruby/irb] Added setup and teardown to TestIRB::TestInit
Not to be affected by existing rc files in all tests.

bf434892b4
2021-04-26 21:15:06 +09:00
Koichi Sasada
1ac68bba4e [ruby/irb] SIGINT should raise Interrupt after IRB session
5832cfe75b
2021-04-02 01:57:44 +09:00
Hiroshi SHIBATA
0dc95266e8
Fix the failing test with XDG_CONFIG_HOME 2021-01-12 20:15:18 +09:00
Nobuyoshi Nakada
84b873e381 [ruby/irb] Restore environment variables
236590882c
2019-12-14 00:39:53 +09:00
aycabta
bc0da8e3ff Generate history file path correctly when $HOME/.irbrc doesn't exist 2019-11-20 08:19:58 +09:00
kazu
38f137276d Suppress read of ~/.irbrc
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64433 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-18 04:09:48 +00:00
k0kubun
89c7e6de44 irb/test_init.rb: add test to ensure $0
is not changed.

At first `ARGV.unshift('something')` was suggested for r61149,
but it wasn't sufficient because it modifies $0.

Not only to preserve ARGV, but also r61149 intends to preserve $0.
This test prevents future breakage of the behavior.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61167 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-12 13:56:48 +00:00
k0kubun
da1ba13714 irb.rb: preserve ARGV on binding.irb
This is not perfectly good solution (at least we don't want to have ARGV
as default value of `argv` argument), but unfortunately IRB.setup and
IRB.parse_opts are public methods and we can't make breaking change to
those methods.

We may deprecate using them and then make them private in the future,
but the removal should not be in Ruby 2.5. So I kept their interface for
now.

[Bug #14162] [close GH-1770]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61149 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-12 11:25:16 +00:00