From 821692e6be43390b694200d070e7e622022ddd2f Mon Sep 17 00:00:00 2001 From: Dave Benvenuti Date: Wed, 8 Jan 2025 11:32:06 -0800 Subject: [PATCH 1/2] Check REGENERATE_TYPED_TESTS environment variable to make working with this particular test easier --- test/codegen_test.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/codegen_test.rb b/test/codegen_test.rb index f099c24..889e49d 100644 --- a/test/codegen_test.rb +++ b/test/codegen_test.rb @@ -554,6 +554,8 @@ def test_generate_types # While this is not great, writing tests that ensure that signatures are generated # correctly without pulling in all of sorbet is at the very least incredibly complex. # So this is the solution for now. + File.write("test/fixtures/typed_test.correct.rb", gen.to_ruby) if ENV["REGENERATE_TYPED_TESTS"] == "true" + assert_equal(File.read("test/fixtures/typed_test.correct.rb"), gen.to_ruby) end From f0c522ad507874b0c4baa4f3a23aa4799deef0c7 Mon Sep 17 00:00:00 2001 From: Dave Benvenuti Date: Wed, 8 Jan 2025 13:59:31 -0800 Subject: [PATCH 2/2] WIP need to move parse_file somewhere --- Rakefile | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Rakefile b/Rakefile index 604b77e..ddaeed9 100644 --- a/Rakefile +++ b/Rakefile @@ -104,3 +104,13 @@ task bench: [BENCHMARK_UPSTREAM_PB, BENCHMARK_PROTOBOEUF_PB] do puts "###### YJIT ######" ruby "--yjit -I lib:bench/lib bench/benchmark.rb" end + +desc "Regenerate test/fixtures/typed_test.correct.rb" +task :regenerate_typed_test_fixture do + parsed = ProtoBoeuf.parse_file("test/fixtures/typed_test.proto") + gen = CodeGen.new(unit, generate_types: true) + + File.write("test/fixtures/typed_test.correct.rb", gen.to_ruby) + + puts "Regenerated test/fixtures/typed_test.correct.rb" +end