forked from ruby/prism
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserialization.rake
More file actions
31 lines (26 loc) · 1.07 KB
/
serialization.rake
File metadata and controls
31 lines (26 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# frozen_string_literal: true
task "test:java_loader" do
# Recompile with PRISM_SERIALIZE_ONLY_SEMANTICS_FIELDS=1
# Due to some JRuby bug this does not get propagated to the compile task, so require the caller to set the env var
# ENV["PRISM_SERIALIZE_ONLY_SEMANTICS_FIELDS"] = "1"
raise "this task requires $SERIALIZE_ONLY_SEMANTICS_FIELDS to be set" unless ENV["PRISM_SERIALIZE_ONLY_SEMANTICS_FIELDS"]
Rake::Task["clobber"].invoke
Rake::Task["test:java_loader:internal"].invoke
end
task "test:java_loader:internal" => :compile do
fixtures = File.expand_path("../test/prism/fixtures", __dir__)
$:.unshift(File.expand_path("../lib", __dir__))
require "prism"
raise "this task requires the FFI backend" unless Prism::BACKEND == :FFI
require "fileutils"
require 'java'
require_relative '../tmp/prism.jar'
Dir["**/*.txt", base: fixtures].each do |relative|
path = "#{fixtures}/#{relative}"
puts
puts path
serialized = Prism.dump_file(path)
parse_result = org.ruby_lang.prism.Loader.load(serialized.unpack('c*'))
puts parse_result.value
end
end