Skip to content

Commit

Permalink
Merge pull request #98 from casperisfine/github-actions
Browse files Browse the repository at this point in the history
Migrate to GitHub actions and fixes various issues
  • Loading branch information
byroot committed May 7, 2021
2 parents e441305 + 2af3225 commit 829c22d
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 97 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/ci.yml
@@ -0,0 +1,53 @@
name: CI

on: [push, pull_request]

jobs:
ubuntu:
strategy:
fail-fast: false
matrix:
ruby: [ '3.0', '2.7', '2.6', '2.5', 'jruby', 'truffleruby' ]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install Node
run: sudo apt-get install -y nodejs
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
- name: Update Rubygems
run: gem update --system
- name: Install bundler
run: gem install bundler -v '2.2.16'
- name: Install dependencies
run: bundle install
- name: Run test
run: rake
- name: Install gem
run: rake install
macos:
strategy:
fail-fast: false
matrix:
ruby: [ '3.0', '2.7', '2.6', '2.5' ]
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
- name: Update Rubygems
run: gem update --system
- name: Install bundler
run: gem install bundler -v '2.2.16'
- name: Install dependencies
run: bundle install
- name: Run test
run: rake
- name: Install gem
run: rake install
87 changes: 0 additions & 87 deletions .travis.yml

This file was deleted.

1 change: 1 addition & 0 deletions lib/execjs/mini_racer_runtime.rb
Expand Up @@ -6,6 +6,7 @@ class Context < Runtime::Context
def initialize(runtime, source = "", options={})
source = encode(source)
@context = ::MiniRacer::Context.new
@context.eval("delete this.console");
translate do
@context.eval(source)
end
Expand Down
5 changes: 4 additions & 1 deletion lib/execjs/runtimes.rb
Expand Up @@ -24,7 +24,10 @@ module Runtimes

JavaScriptCore = ExternalRuntime.new(
name: "JavaScriptCore",
command: "/System/Library/Frameworks/JavaScriptCore.framework/Versions/A/Resources/jsc",
command: [
"/System/Library/Frameworks/JavaScriptCore.framework/Versions/Current/Helpers/jsc",
"/System/Library/Frameworks/JavaScriptCore.framework/Versions/A/Resources/jsc",
],
runner_path: ExecJS.root + "/support/jsc_runner.js"
)

Expand Down
1 change: 1 addition & 0 deletions lib/execjs/support/node_runner.js
Expand Up @@ -28,4 +28,5 @@
this.process = __process__;
print(JSON.stringify(['err', '' + err, err.stack]));
}
__process__.exit(0);
});
28 changes: 19 additions & 9 deletions test/test_execjs.rb
Expand Up @@ -104,21 +104,21 @@ def test_context_call_missing_function
'"\\\\"' => "\\"
}.each_with_index do |(input, output), index|
define_method("test_exec_string_#{index}") do
assert_equal output, ExecJS.exec("return #{input}")
assert_output output, ExecJS.exec("return #{input}")
end

define_method("test_eval_string_#{index}") do
assert_equal output, ExecJS.eval(input)
assert_output output, ExecJS.eval(input)
end

define_method("test_compile_return_string_#{index}") do
context = ExecJS.compile("var a = #{input};")
assert_equal output, context.eval("a")
assert_output output, context.eval("a")
end

define_method("test_compile_call_string_#{index}") do
context = ExecJS.compile("function a() { return #{input}; }")
assert_equal output, context.call("a")
assert_output output, context.call("a")
end
end

Expand All @@ -145,25 +145,25 @@ def test_context_call_missing_function
json_value = JSON.generate(value, quirks_mode: true)

define_method("test_json_value_#{index}") do
assert_equal value, JSON.parse(json_value, quirks_mode: true)
assert_output value, JSON.parse(json_value, quirks_mode: true)
end

define_method("test_exec_value_#{index}") do
assert_equal value, ExecJS.exec("return #{json_value}")
assert_output value, ExecJS.exec("return #{json_value}")
end

define_method("test_eval_value_#{index}") do
assert_equal value, ExecJS.eval("#{json_value}")
assert_output value, ExecJS.eval("#{json_value}")
end

define_method("test_strinigfy_value_#{index}") do
context = ExecJS.compile("function json(obj) { return JSON.stringify(obj); }")
assert_equal json_value, context.call("json", value)
assert_output json_value, context.call("json", value)
end

define_method("test_call_value_#{index}") do
context = ExecJS.compile("function id(obj) { return obj; }")
assert_equal value, context.call("id", value)
assert_output value, context.call("id", value)
end
end

Expand Down Expand Up @@ -421,4 +421,14 @@ def test_uglify
assert_equal "function foo(bar){return bar}",
context.call("uglify", "function foo(bar) {\n return bar;\n}")
end

private

def assert_output(expected, actual)
if expected.nil?
assert_nil actual
else
assert_equal expected, actual
end
end
end

0 comments on commit 829c22d

Please sign in to comment.