aboutsummaryrefslogtreecommitdiffstats
path: root/test/ruby/test_autoload.rb
Commit message (Collapse)AuthorAgeFilesLines
* fix for multi-run test.Koichi Sasada2020-05-151-6/+9
| | | | | | | | TestAutoload#test_source_location can't run multiple test-run so that use assert_separately(). repro command: make yes-test-all TESTS='--repeat-count=50 ruby/test_autoload -n test_source_location'
* Suffixed memory leak tests as "memory_leak"Nobuyoshi Nakada2020-05-071-2/+3
| | | | So that `TEST_EXCLUDES` option in common.mk works.
* Fix source location of autoloaded constant [Bug #16764]Nobuyoshi Nakada2020-04-071-0/+13
|
* support multi-run for test/ruby/test_autoload.rbKoichi Sasada2020-01-281-0/+2
| | | | Another test defines Object::A, but it will fail 2nd test.
* support multi-run for ruby/test_autoload.rbKoichi Sasada2020-01-281-0/+1
| | | | It requires more cleanup.
* Do not load files in build directoryKazuhiro NISHIYAMA2019-12-111-18/+18
| | | | related https://bugs.ruby-lang.org/issues/16177
* Do not lose existing constant visibility when autoloadingJeremy Evans2019-12-031-0/+60
| | | | | | | | | | This copies the private/deprecate constant visibility across the autoload. It still is backwards compatible with setting the private/deprecate constant visibility in the autoloaded file. However, if you explicitly set public constant in the autoloaded file, that will be reset after the autoload. Fixes [Bug #11055]
* Add a testKazuhiro NISHIYAMA2019-11-191-3/+23
| | | | | | and rename from b.rb [ruby-core:95055] [Bug #16177]
* Suppress void context warning in verbose modeNobuyoshi Nakada2019-06-281-1/+1
|
* Add an optional `inherit` argument to Module#autoload?Jean Boussier2019-06-211-0/+4
| | | | | | [Feature #15777] Closes: https://github.com/ruby/ruby/pull/2173
* Avoid triggering autoload in Module#const_defined?(String)Jean Boussier2019-05-071-0/+6
| | | | [Bug #15780]
* test_array.rb: increase timeout for RubyCIk0kubun2018-12-281-1/+1
| | | | | | | | | | | | to prevent random failures. test/ruby/test_autoload.rb: ditto test/ruby/test_optimization.rb: ditto https://rubyci.org/logs/rubyci.s3.amazonaws.com/scw-9d6766/ruby-trunk/log/20181228T101706Z.fail.html.gz https://rubyci.org/logs/mswinci.japaneast.cloudapp.azure.com/vc12-x64/ruby-trunk/log/20181228T114549Z.fail.html.gz git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66614 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* try to remove some test skips for MJITk0kubun2018-10-211-1/+0
| | | | | | | | | Eric Wong made some effort to keep compatibility around fd with MJIT. Also I'm hoping r65279 (and r65280) eliminates major MJIT bugs, so I want to start solely testing MJIT. Other test skips branched by MJIT enablement seemed reasonable to me. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65285 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* test: skip 2 major unstable tests with MJITk0kubun2018-06-261-0/+1
| | | | | | | | | for CI with cppflags=-DMJIT_FORCE_ENABLE. Since I have no idea to fix this immediately, let me skip this for now and take a look later. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63752 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* variable.c: fix multiple autoload with identical file (again)normal2018-05-101-0/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We need to ensure autoload declarations pointing to the same feature (aka "file") can wait on each other to avoid deadlock situations. So, reorganize autoload data structures to maintain a feature => autoload_data_i mapping, and have module constant tables point to the new autoload_const struct instead of directly to autoload_data_i. This allows multiple autoload_const structs to refer to the SAME autoload_data_i struct, and with it, the on-stack autoload_state.waitq. The end result is different constants can share the same waitq (tied to the feature name), and not deadlock each other during loading. Thanks to Eugene Kenny for the bug report and reproducible test case. Reported-by: Eugene Kenny <elkenny@gmail.com> * variable.c (autoload_featuremap): new global (struct autoload_const): new per-const struct (struct autoload_state): reference autoload_const instead of autoload_data_i (struct autoload_data_i): remove per-const (autoload_i_mark): delete from autoload_featuremap if unreferenced (autoload_c_mark): new dmark callback (autoload_c_free): new dfree callback (autoload_c_memsize): new memsize callback (autoload_const_type): new data type (get_autoload_data): set autoload_const as well (rb_autoload_str): use new data structures (autoload_delete): cleanup from autoload_featuremap (check_autoload_required): adjust for new internals (rb_autoloading_value): ditto (struct autoload_const_set_args): remove, redundant with autoload_const (const_tbl_update): adjust for new internals (autoload_const_set): ditto (autoload_require): ditto (autoload_reset): ditto (rb_autoload_load): ditto (rb_const_set): ditto (current_autoload_data): ditto (set_const_visibility): ditto * test/ruby/test_autoload.rb (test_autoload_same_file): new test (test_no_leak): new test [ruby-core:86935] [Bug #14742] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63392 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* revert r63387 and r63389 for nownormal2018-05-101-36/+0
| | | | | | | | I can't reproduce the problem on my 32-bit machine, and I have connectivity problems to my 64-bit systems at the moment. Will revisit in a few hours hopefully. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63390 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* variable.c: fix autoload object lifetimes and leaknormal2018-05-101-0/+12
| | | | | | | | | We must not call normal Hash methods inside GC free callback, either, however identity hash may be used. [ruby-core:86935] [Bug #14742] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63389 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* variable.c: fix multiple autoload with identical filenormal2018-05-101-0/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We need to ensure autoload declarations pointing to the same feature (aka "file") can wait on each other to avoid deadlock situations. So, reorganize autoload data structures to maintain a feature => autoload_data_i mapping, and have module constant tables point to the new autoload_const struct instead of directly to autoload_data_i. This allows multiple autoload_const structs to refer to the SAME autoload_data_i struct, and with it, the on-stack autoload_state.waitq. The end result is different constants can share the same waitq (tied to the feature name), and not deadlock each other during loading. Thanks to Eugene Kenny for the bug report and reproducible test case. Reported-by: Eugene Kenny <elkenny@gmail.com> * variable.c (autoload_featuremap): new global (struct autoload_const): new per-const struct (struct autoload_state): reference autoload_const instead of autoload_data_i (struct autoload_data_i): remove per-const (autoload_i_mark): delete from autoload_featuremap if unreferenced (autoload_c_mark): new dmark callback (autoload_c_free): new dfree callback (autoload_c_memsize): new memsize callback (autoload_const_type): new data type (get_autoload_data): set autoload_const as well (rb_autoload_str): use new data structures (autoload_delete): cleanup from autoload_featuremap (check_autoload_required): adjust for new internals (rb_autoloading_value): ditto (struct autoload_const_set_args): remove, redundant with autoload_const (const_tbl_update): adjust for new internals (autoload_const_set): ditto (autoload_require): ditto (autoload_reset): ditto (rb_autoload_load): ditto (rb_const_set): ditto (current_autoload_data): ditto (set_const_visibility): ditto * test/ruby/test_autoload.rb (test_autoload_same_file): new test [ruby-core:86935] [Bug #14742] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63387 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* variable.c: fix thread + fork errors in autoloadnormal2018-04-201-0/+26
| | | | | | | | | | | | | | | | | | | | | | | This is fairly non-intrusive bugfix to prevent children from trying to reach into thread stacks of the parent. I will probably reuse this idea and redo r62934, too (same bug). * vm_core.h (typedef struct rb_vm_struct): add fork_gen counter * thread.c (rb_thread_atfork_internal): increment fork_gen * variable.c (struct autoload_data_i): store fork_gen * variable.c (check_autoload_data): remove (replaced with get_...) * variable.c (get_autoload_data): check fork_gen when retrieving * variable.c (check_autoload_required): use get_autoload_data * variable.c (rb_autoloading_value): ditto * variable.c (rb_autoload_p): ditto * variable.c (current_autoload_data): ditto * variable.c (autoload_reset): reset fork_gen, adjust indent * variable.c (rb_autoload_load): set fork_gen when setting state * test/ruby/test_autoload.rb (test_autoload_fork): new test [ruby-core:86410] [Bug #14634] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63210 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* variable.c: flags at autoloadingnobu2018-02-131-0/+40
| | | | | | | | * variable.c (const_tbl_update): flags by deprecate_constant / private_constant set during autoloading should be preserved after required. [ruby-core:85516] [Bug #14469] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62395 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* revert r62392usa2018-02-131-40/+0
| | | | | | | | check the declaration of `rb_autoloading_value()` in vm_core.h and the call in vm_insnhelper.c, and retry it. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62393 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* variable.c: flags at autoloadingnobu2018-02-131-0/+40
| | | | | | | | * variable.c (const_tbl_update): flags by deprecate_constant / private_constant set during autoloading should be preserved after required. [ruby-core:85516] [Bug #14469] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62392 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Remove unnecessary `require 'thread'`kazu2017-10-081-1/+0
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60139 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* variable.c: cleanup waitq upon thread deathnormal2017-05-071-0/+5
| | | | | | | | | | | | | * variable.c (autoload_reset): use idempotent list_del_init (autoload_sleep): moved code from rb_autoload_load (autoload_sleep_done): cleanup for use with rb_ensure (rb_autoload_load): ensure list delete happens in case the thread dies during sleep * test/ruby/bug-13526.rb: new script for separate execution * test/ruby/test_autoload.rb (test_bug_13526): new test [ruby-core:81016] [Bug #13526] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58587 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* test/ruby: suppress runtime warningsnobu2016-02-191-2/+8
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53873 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Add frozen_string_literal: false for all filesnaruse2015-12-161-0/+1
| | | | | | 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
* variable.c (rb_autoload_load): allow recursive callsnormal2015-11-091-0/+19
| | | | | | | | | | * variable.c (rb_autoload_load): allow recursive calls [ruby-core:71345] [Bug #11658] * test/ruby/test_autoload.rb (test_autoload_while_autoloading): new test by: Hiroshi Shirosaki <h.shirosaki@gmail.com> [ruby-core:71390] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52511 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* test/ruby/test_autoload: hoist out ruby_impl_requirenormal2015-11-051-15/+18
| | | | | | | | Having "require" implemented in Ruby is the common case nowadays with RubyGems, so ensure it is easy-to-reuse the same logic for future tests. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52459 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* test_autoload.rb: use class_evalnobu2015-05-181-10/+2
| | | | | | | | | * test/ruby/test_autoload.rb (add_autoload): use class_eval instead of string eval. * test/ruby/test_autoload.rb (remove_autoload_constant): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50529 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * load.c (loaded_feature_path): stop returning false negatives fortenderlove2015-05-161-0/+26
| | | | | | | | | | filenames which are trailing substrings of file extensions. For example, 'b', which a trailing substring of ".rb" should not return false. [Bug #11155][ruby-core:69206] * test/ruby/test_autoload.rb: test for fix git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * variable.c: Change autoload to call `require` through Ruby rathertenderlove2015-05-141-0/+25
| | | | | | | | | | than directly calling `rb_require_safe`. This allows things like RubyGems to intercept file loading done though `autoload`. [Feature #11140] * test/ruby/test_autoload.rb: Test for change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50494 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * test/ruby/test_autoload.rb (class TestAutoload): change load targettarui2014-11-261-3/+3
| | | | | | | | from Continuation to Date. Becouse Continuation is no longer quiet. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48592 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * test/lib/envutil.rb: Moved from test/ruby/.akr2014-11-131-1/+0
| | | | | | | | | | | | | | * 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
* * test/ruby/envutil.rb (default_warning): New method.akr2014-06-011-2/+2
| | | | | | | | * test/ruby/test_autoload.rb: Use EnvUtil.default_warning. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46310 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Use EnvUtil.suppress_warning.akr2014-06-011-32/+28
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46300 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Suppress a warning.akr2014-06-011-0/+5
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46299 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Suppress a warning.akr2014-06-011-0/+5
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46294 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * test/csv/test_features.rb, test/logger/test_logger.rbakr2013-04-201-84/+78
| | | | | | | | | | | | | | | | | | test/mkmf/test_have_macro.rb, test/net/http/test_http.rb, test/openssl/test_config.rb, test/psych/test_encoding.rb, test/psych/test_exception.rb, test/psych/test_psych.rb, test/psych/test_tainted.rb, test/readline/test_readline.rb, test/rexml/test_contrib.rb, test/ruby/test_autoload.rb, test/ruby/test_beginendblock.rb, test/ruby/test_exception.rb, test/ruby/test_file.rb, test/ruby/test_io.rb, test/ruby/test_marshal.rb, test/ruby/test_process.rb, test/ruby/test_require.rb, test/ruby/test_rubyoptions.rb, test/syslog/test_syslog_logger.rb, test/webrick/test_httpauth.rb, test/zlib/test_zlib.rb: Use Tempfile.create. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40400 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * test/ruby/test_autoload.rb: remove temporally files early.akr2012-07-181-0/+12
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36446 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * test/ruby/test_autoload.rb: clear autoloaded paths.nobu2012-04-121-0/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35311 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * insns.def (defineclass), vm_insnhelper.c (vm_get_cvar_base): seenobu2011-09-011-1/+3
| | | | | | | | also inherited constants for classes without superclass and modules. [ruby-core:37698] [Bug #3423] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33157 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * Re-apply r33078, thread-safe autoload which is reverted at r33093.nahi2011-08-311-0/+110
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33146 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * Revert r33078. It caused a Rails application NoMethodError.nahi2011-08-271-110/+0
| | | | | | | | /home/nahi/git/emptyApp/ruby/1.9.1/gems/rack-mount-0.6.14/lib/rack/mount/utils.rb:157: warning: toplevel constant ScanError referenced by Regin::Parser::ScanError /home/nahi/git/emptyApp/ruby/1.9.1/gems/rack-mount-0.6.14/lib/rack/mount/vendor/regin/regin/parser.rb:17:in `parse_regexp': undefined method `scan_str' for #<Regin::Parser:0x00000002344548> (NoMethodError) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33093 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * variable.c: Make autoload thread-safe. See #921.nahi2011-08-261-0/+110
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | What's the problem? autoload is thread unsafe. When we define a constant to be autoloaded, we expect the constant construction is invariant. But current autoload implementation allows other threads to access the constant while the first thread is loading a file. What's happening inside? The current implementation uses Qundef as a marker of autoload in Constant table. Once the first thread find Qundef as a value at constant lookup, it starts loading a defined feature. Generally a loaded file overrides the Qundef in Constant table by module/class declaration at very beginning lines of the file, so other threads can see the new Module/Class object before feature loading is finished. It breaks invariant construction. How to solve? To ensure invariant constant construction, we need to override Qundef with defined Object after the feature loading. For keeping Qundef in Constant table, I expanded autoload_data struct in Module to have a slot for keeping the defined object while feature loading. And changed Module's constant lookup/update logic a little so that the slot is only visible from the thread which invokes feature loading. (== the first thread which accessed the autoload constant) Evaluation? All test passes (bootstrap test, test-all and RubySpec) and added 8 tests for threading behavior. Extra logics are executed only when Qundef is found, so no perf drop should happen except autoloading. * variable.c (rb_autoload): Prepare new autoload_data struct. * variable.c (rb_autoload_load): Load feature and update Constant table after feature loading is finished. * variable.c (rb_const_get_0): When the fetched constant is under autoloading, it returns the object only for the thread which starts autoloading. * variable.c (rb_const_defined_0): Ditto. * variable.c (rb_const_set): When the specified constant is under autoloading, it sets the object only for the thread which starts autoloading. Otherwise, simply overrides Qundef with constant override warning. * vm_insnhelper.c (vm_get_ev_const): Apply same change as rb_const_get_0 in variable.c. * test/ruby/test_autoload.rb: Added tests for threading behavior. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33078 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * test/ruby/test_autoload.rb: remove temporary directory.akr2011-06-141-12/+13
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32081 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * variable.c (rb_autoload_p): search superclasses as same as actualnobu2011-04-141-0/+18
| | | | | | loading. fixes [ruby-core:35679] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31279 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Surpress warnings: possibly useless use of :: in void contextnaruse2011-02-051-2/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30801 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * load.c (rb_get_expanded_load_path): always expand load paths.nobu2011-02-051-0/+25
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30789 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * load.c (rb_feature_provided): fixed for autoloading extensionnobu2009-09-091-0/+12
library without suffix. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24817 b2dd03c8-39d4-4d8f-98ff-823fe69b080e