summaryrefslogtreecommitdiff
path: root/test/ruby/test_require.rb
AgeCommit message (Collapse)Author
2019-11-18Deprecate taint/trust and related methods, and make the methods no-opsJeremy Evans
This removes the related tests, and puts the related specs behind version guards. This affects all code in lib, including some libraries that may want to support older versions of Ruby. Notes: Merged: https://github.com/ruby/ruby/pull/2476
2019-11-18Warn on access/modify of $SAFE, and remove effects of modifying $SAFEJeremy Evans
This removes the security features added by $SAFE = 1, and warns for access or modification of $SAFE from Ruby-level, as well as warning when calling all public C functions related to $SAFE. This modifies some internal functions that took a safe level argument to no longer take the argument. rb_require_safe now warns, rb_require_string has been added as a version that takes a VALUE and does not warn. One public C function that still takes a safe level argument and that this doesn't warn for is rb_eval_cmd. We may want to consider adding an alternative method that does not take a safe level argument, and warn for rb_eval_cmd. Notes: Merged: https://github.com/ruby/ruby/pull/2476
2019-11-12test/ruby/test_require.rb: Remove the tests of require with $SAFEYusuke Endoh
The taint mechanism is decided to be removed at 2.7. [Feature #16131] So, this change removes the tests that expects a SecurityError when requiring a file under $SAFE >= 1. The reason why they should be removed in advance is because the upstream of rubygems has already removed a call to "untaint" method, which makes the tests fail.
2019-08-17Use the original require for test_race_exceptionHiroshi SHIBATA
The extension for require method with rubygems affects this test case. We need to keep this test for the original method.
2019-08-09Should require without wrapper moduleNobuyoshi Nakada
2019-08-08Reduce unnecessary EXEC_TAG in requireNobuyoshi Nakada
2019-08-04Revert "Skip test_race_exception on MJIT for now"Takashi Kokubun
This reverts commit 7a75baa6e294473f02da512c99f7ef1f76b2d83c. Revert "Defer skip to avoid errors on ensure" This reverts commit adfc8d6dbadbccef27d6ec78022650840c7604cc. because 76e2370f132f83c16c9de39a0a9356579f364527 is hoped to fix the problem.
2019-08-04Defer skip to avoid errors on ensureTakashi Kokubun
2019-08-04Skip test_race_exception on MJIT for nowTakashi Kokubun
somehow the test fails only on Wercker in CIs triggered by GitHub. Actually rubyci and ci.rvm.jp also have issues too, though.
2019-07-11$LOAD_PATH.resolve_feature_pathNobuyoshi Nakada
Moved from RubyVM. [Feature #15903]
2019-06-30Suppress void context warnings in verbose modeNobuyoshi Nakada
2019-05-25Avoid to show warning message with unused variable.Hiroshi SHIBATA
2018-12-31load.c: resolve_feature_pathnobu
* load.c (rb_resolve_feature_path): search the path for already loaded feature. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66661 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-28`$SAFE` as a process global state. [Feature #14250]ko1
* vm_core.h (rb_vm_t): move `rb_execution_context_t::safe_level` to `rb_vm_t::safe_level_` because `$SAFE` is a process (VM) global state. * vm_core.h (rb_proc_t): remove `rb_proc_t::safe_level` because `Proc` objects don't need to keep `$SAFE` at the creation. Also make `is_from_method` and `is_lambda` as 1 bit fields. * cont.c (cont_restore_thread): no need to keep `$SAFE` for Continuation. * eval.c (ruby_cleanup): use `rb_set_safe_level_force()` instead of access `vm->safe_level_` directly. * eval_jump.c: End procs `END{}` doesn't keep `$SAFE`. * proc.c (proc_dup): removed and introduce `rb_proc_dup` in vm.c. * safe.c (rb_set_safe_level): don't check `$SAFE` 1 -> 0 changes. * safe.c (safe_setter): use `rb_set_safe_level()`. * thread.c (rb_thread_safe_level): `Thread#safe_level` returns `$SAFE`. It should be obsolete. * transcode.c (load_transcoder_entry): `rb_safe_level()` only returns 0 or 1 so that this check is not needed. * vm.c (vm_proc_create_from_captured): don't need to keep `$SAFE` for Proc. * vm.c (rb_proc_create): renamed to `proc_create`. * vm.c (rb_proc_dup): moved from proc.c. * vm.c (vm_invoke_proc): do not need to set and restore `$SAFE` for `Proc#call`. * vm_eval.c (rb_eval_cmd): rename a local variable to represent clearer meaning. * lib/drb/drb.rb: restore `$SAFE`. * lib/erb.rb: restore `$SAFE`, too. * test/lib/leakchecker.rb: check `$SAFE == 0` at the end of tests. * test/rubygems/test_gem.rb: do not set `$SAFE = 1`. * bootstraptest/test_proc.rb: catch up this change. * spec/ruby/optional/capi/string_spec.rb: ditto. * test/bigdecimal/test_bigdecimal.rb: ditto. * test/fiddle/test_func.rb: ditto. * test/fiddle/test_handle.rb: ditto. * test/net/imap/test_imap_response_parser.rb: ditto. * test/pathname/test_pathname.rb: ditto. * test/readline/test_readline.rb: ditto. * test/ruby/test_file.rb: ditto. * test/ruby/test_optimization.rb: ditto. * test/ruby/test_proc.rb: ditto. * test/ruby/test_require.rb: ditto. * test/ruby/test_thread.rb: ditto. * test/rubygems/test_gem_specification.rb: ditto. * test/test_tempfile.rb: ditto. * test/test_tmpdir.rb: ditto. * test/win32ole/test_win32ole.rb: ditto. * test/win32ole/test_win32ole_event.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61510 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-21load.c: real path to loadnobu
* load.c (rb_construct_expanded_load_path): expand load paths to real paths to get rid of duplicate loading from symbolic-linked directories. [Feature #10222] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59984 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-04test_require.rb: fix expected pathnobu
* test/ruby/test_require.rb (test_require_with_unc): remove extra slash. the result of File.expand_path has a slash just follows the drive letter. https://github.com/ruby/ruby/commit/4ef849bd9014746821402e21053a53ea61b3690d#commitcomment-22391133 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59012 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-03test_require.rb: ignore EPERM at UNCnobu
* test/ruby/test_require.rb (test_require_with_unc): ignore EPERM. GetFileAttributes and CreateFile with backup semantics fail at a symlink in a shared folder to another shared folder. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59009 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-03file.c: preserve encodingnobu
* file.c (path_check_0): preserve encoding of path name in warning message. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59008 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-03test/ruby/test_require.rb: remove duplicate assertionnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59005 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-03test_require.rb: untouch default internal encodingnobu
* test/ruby/test_require.rb (assert_require_insecure_path): get rid of setting Encoding.default_internal, which affects load path conversion. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59004 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-02test_require.rb: assert_require_insecure_pathnobu
* test/ruby/test_require.rb (assert_require_insecure_path): more tests for loading insecure path. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58999 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-02test_require.rb: fallback encodingnobu
* test/ruby/test_require.rb (assert_require_nonascii_path): fallback when LANG=C. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58998 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-02test_require.rb: filesystem encodingnobu
* test/ruby/test_require.rb (assert_require_nonascii_path): the path in error message is converted to filesystem encoding. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58997 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-02file.c: preserve encodingnobu
* file.c (rb_find_file_safe): preserve encoding of path in SecurityError messages. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58996 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-11test/ruby/test_require.rb: use squiggly heredocsnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57835 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-07Extend timeout for Solaris unstable10s.shugo
http://rubyci.org/logs/rubyci.s3.amazonaws.com/unstable10s/ruby-trunk/log/20161206T181910Z.fail.html.gz git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57010 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-05Don't insert an entry to loading_tbl if another thread succeed to load.shugo
If rb_thread_shield_wait() returns Qfalse, the file has been successfully loaded by another thread, so there is no need to insert a new entry into loading_tbl. [ruby-core:78464] [Bug #12999] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56985 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-04Increase timeout of TestRequire#test_require_with_loaded_features_popnaruse
unstable10s fails it because of timeout http://rubyci.s3.amazonaws.com/unstable10s/ruby-trunk/log/20161201T161908Z.fail.html.gz git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56982 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-21test_require.rb: reduce GCnobu
* test/ruby/test_require.rb (test_loading_fifo_fd_leak): invoke GC only when FDs exhausted to reduce the test time. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56462 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-10ruby.c: bind fd before waitingnobu
* ruby.c (open_load_file): bind the open fd to an IO instance before waiting FIFO, not to leak the fd if interrupted. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56388 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-10test_require.rb: use assert_separatelynobu
* test/ruby/test_require.rb (test_loading_fifo_threading_raise): use assert_separately. * test/ruby/test_require.rb (test_loading_fifo_threading_success): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56387 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-06load.c: setup syntax error backtracenobu
* load.c (rb_require_safe): SyntaxError created by the parser just has the mesage and needs to set up the backtrace. [ruby-core:77491] [Bug #12811] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56363 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-06load.c: fix load/require contextnobu
* load.c (rb_load_internal0): load/require is not the main script. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56362 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-08* test/ruby/test_require.rb (test_require_with_loaded_features_pop):headius
Only remove PATH so threads don't accidentally double-pop. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54037 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-16Add frozen_string_literal: false for all filesnaruse
When you change this to true, you may need to add more tests. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53141 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-18* ruby/test_require.rb (loading_fifo): checking by defined? is meaningless aboutusa
notimplemented method. such methods are defined, but not respond_to?. this fixes test failures introduced at r52172. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52187 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-18test_require.rb: no guarantees to load FIFOnobu
* test/ruby/test_require.rb (loading_fifo): loading from FIFO is not guaranteed, it just should not block the whole process. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52173 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-18test_require.rb: test conditionsnobu
* test/ruby/test_require.rb (loading_fifo): check by if FIFO is available or not, instead of platform names. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52172 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-17* ruby.c (open_load_file): reset O_NONBLOCK after open.kosaki
Even if S_ISREG() is true, the file may be file on FUSE filesystem or something. We can't assume O_NONBLOCK is safe. Moreover, we should wait if the path is point to FIFO. That's FIFO semantics. GVL should be transparent from ruby script. Thus, just reopen without O_NONBLOCK for filling the requirements. [Bug #11060][Bug #11559] * ruby.c (loadopen_func): new for the above. * file.c (ruby_is_fd_loadable): new. for checks loadable file type of not. * file.c (rb_file_load_ok): use ruby_is_fd_loadble() * internal.h: add ruby_is_fd_loadble() * common.mk: now, ruby.o depend on thread.h. * test/ruby/test_require.rb (TestRequire#test_loading_fifo_threading_success): new test. This test successful case that loading from FIFO. * test/ruby/test_require.rb (TestRequire#test_loading_fifo_threading_raise): rename from test_loading_fifo_threading. You souldn't rescue an exception if you test raise or not. Moreover, this case should be caught IOError because load(FIFO) should be blocked until given any input. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52151 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-16file.c: non-blocking opennobu
* file.c (rb_file_load_ok): open in non-blocking mode withoout releasing GVL. don't care about others than regular files and directories. [ruby-dev:49272] [Bug #11559] * ruby.c (load_file_internal): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52139 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-28test: File.symlink needs administrator privilegenobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51714 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-30envutil.rb: -w for assert_separatelynobu
* test/lib/envutil.rb (assert_separately): always add -w option for warnings. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51445 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-30load.c: avoid segfault when 'throw' occurs in the middle of rb_load_file_strnobu
How can a 'throw' happen while the current thread is reading a Ruby source file from disk and parsing it? It can happen if another thread calls Thread#raise, and passes an Exception object which responds to #exception, and the custom #exception method calls Kernel#throw. In practice, this is most likely to happen if you combine the use of autoload and Timeout.timeout. An extra check is required to avoid a segfault in this case. * load.c (rb_load_internal0): extra check before returning TAG_RAISE when a non-local transfer of control happens while loading and parsing a Ruby source file. [ruby-core:70169] [Bug #11404] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51439 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-28class.c: TypeError when superclass mismatchnobu
* class.c (rb_define_class_id_under): raise TypeError exception same as ruby level class definition when superclass mismatch. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51048 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-14test_require.rb: wait loadignobu
* test/ruby/test_require.rb (test_loading_fifo_threading): wait until the main thread blocks by loading. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50902 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-14* test/ruby/test_require.rb (TestRequire#test_loading_fifo_threading): omit onusa
Windows. the platform does not support fifo. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50896 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-14file.c: open without gvlnobu
* file.c (rb_file_load_ok): try opening file without gvl not to lock entire process. [Bug #11060] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50887 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-16fix test failures introduced in r50494tenderlove
This commit changes some of the `require` tests to run *without* rubygems enabled. Those particular tests were removing rubygems from $LOAD_PATH. These tests assert that a `LoadError` is raised. Unfortunately, since RubyGems was enabled by default and was not fully loaded, the load error actually originated from RubyGems, *not* from where the tests intended. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50513 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-13* test/lib/envutil.rb: Moved from test/ruby/.akr
* test/lib/find_executable.rb: Ditto. * test/lib/memory_status.rb: Ditto. * test/lib/test/unit.rb: require envutil. * test/: Don't require envutil in test files. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48409 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-29load.c: transcode pathnobu
* load.c (rb_f_load): path name needs to be transcoded to OS path encoding. [ruby-list:49994] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48186 b2dd03c8-39d4-4d8f-98ff-823fe69b080e