ruby-changes:36094
From: nobu <ko1@a...>
Date: Tue, 28 Oct 2014 16:22:58 +0900 (JST)
Subject: [ruby-changes:36094] nobu:r48175 (trunk): ruby.c: no -r when dump
nobu 2014-10-28 16:22:43 +0900 (Tue, 28 Oct 2014) New Revision: 48175 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=48175 Log: ruby.c: no -r when dump * ruby.c (process_options, load_file_internal2): should not require other files when dump option is given. [ruby-dev:48712] [Bug #10435] Modified files: trunk/ChangeLog trunk/ruby.c trunk/test/ruby/test_rubyoptions.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 48174) +++ ChangeLog (revision 48175) @@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Tue Oct 28 16:22:41 2014 Nobuyoshi Nakada <nobu@r...> + + * ruby.c (process_options, load_file_internal2): should not + require other files when dump option is given. + [ruby-dev:48712] [Bug #10435] + Tue Oct 28 14:51:38 2014 NARUSE, Yui <naruse@r...> * configure.in: remove apple-gcc4.2 from CC candidates. Index: ruby.c =================================================================== --- ruby.c (revision 48174) +++ ruby.c (revision 48175) @@ -1415,8 +1415,10 @@ process_options(int argc, char **argv, s https://github.com/ruby/ruby/blob/trunk/ruby.c#L1415 eenc = lenc; } rb_enc_associate(opt->e_script, eenc); - ruby_set_script_name(opt->script_name); - require_libraries(&opt->req_list); + if (!(opt->dump & ~DUMP_BIT(version_v))) { + ruby_set_script_name(opt->script_name); + require_libraries(&opt->req_list); + } ruby_set_script_name(progname); PREPARE_PARSE_MAIN({ @@ -1612,8 +1614,10 @@ load_file_internal2(VALUE argp_v) https://github.com/ruby/ruby/blob/trunk/ruby.c#L1614 if (f != rb_stdin) rb_io_close(f); f = Qnil; } - ruby_set_script_name(opt->script_name); - require_libraries(&opt->req_list); /* Why here? unnatural */ + if (!(opt->dump & ~DUMP_BIT(version_v))) { + ruby_set_script_name(opt->script_name); + require_libraries(&opt->req_list); /* Why here? unnatural */ + } } if (opt->src.enc.index >= 0) { enc = rb_enc_from_index(opt->src.enc.index); Index: test/ruby/test_rubyoptions.rb =================================================================== --- test/ruby/test_rubyoptions.rb (revision 48174) +++ test/ruby/test_rubyoptions.rb (revision 48175) @@ -710,4 +710,41 @@ class TestRubyOptions < Test::Unit::Test https://github.com/ruby/ruby/blob/trunk/test/ruby/test_rubyoptions.rb#L710 bug7157 = '[ruby-core:47967]' assert_in_out_err(['-p', '-e', 'sub(/t.*/){"TEST"}'], %[test], %w[TEST], [], bug7157) end + + def assert_norun_with_rflag(opt) + bug10435 = "[ruby-dev:48712] [Bug #10435]: should not run with #{opt} option" + stderr = [] + Tempfile.create(%w"bug10435- .rb") do |script| + dir, base = File.split(script.path) + script.puts "abort ':run'" + script.close + opts = ['-C', dir, '-r', "./#{base}", opt] + assert_in_out_err([*opts, '-ep']) do |_, e| + stderr.concat(e) + end + stderr << "---" + assert_in_out_err([*opts, base]) do |_, e| + stderr.concat(e) + end + end + assert_not_include(stderr, ":run", bug10435) + end + + def test_dump_syntax_with_rflag + assert_norun_with_rflag('-c') + assert_norun_with_rflag('--dump=syntax') + end + + def test_dump_yydebug_with_rflag + assert_norun_with_rflag('-y') + assert_norun_with_rflag('--dump=yydebug') + end + + def test_dump_parsetree_with_rflag + assert_norun_with_rflag('--dump=parsetree') + end + + def test_dump_insns_with_rflag + assert_norun_with_rflag('--dump=insns') + end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/