Skip to content

Commit 829c22d

Browse files
authored
Merge pull request #98 from casperisfine/github-actions
Migrate to GitHub actions and fixes various issues
2 parents e441305 + 2af3225 commit 829c22d

File tree

6 files changed

+78
-97
lines changed

6 files changed

+78
-97
lines changed

.github/workflows/ci.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: CI
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
ubuntu:
7+
strategy:
8+
fail-fast: false
9+
matrix:
10+
ruby: [ '3.0', '2.7', '2.6', '2.5', 'jruby', 'truffleruby' ]
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v2
15+
- name: Install Node
16+
run: sudo apt-get install -y nodejs
17+
- name: Set up Ruby
18+
uses: ruby/setup-ruby@v1
19+
with:
20+
ruby-version: ${{ matrix.ruby }}
21+
- name: Update Rubygems
22+
run: gem update --system
23+
- name: Install bundler
24+
run: gem install bundler -v '2.2.16'
25+
- name: Install dependencies
26+
run: bundle install
27+
- name: Run test
28+
run: rake
29+
- name: Install gem
30+
run: rake install
31+
macos:
32+
strategy:
33+
fail-fast: false
34+
matrix:
35+
ruby: [ '3.0', '2.7', '2.6', '2.5' ]
36+
runs-on: macos-latest
37+
steps:
38+
- name: Checkout
39+
uses: actions/checkout@v2
40+
- name: Set up Ruby
41+
uses: ruby/setup-ruby@v1
42+
with:
43+
ruby-version: ${{ matrix.ruby }}
44+
- name: Update Rubygems
45+
run: gem update --system
46+
- name: Install bundler
47+
run: gem install bundler -v '2.2.16'
48+
- name: Install dependencies
49+
run: bundle install
50+
- name: Run test
51+
run: rake
52+
- name: Install gem
53+
run: rake install

.travis.yml

Lines changed: 0 additions & 87 deletions
This file was deleted.

lib/execjs/mini_racer_runtime.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ class Context < Runtime::Context
66
def initialize(runtime, source = "", options={})
77
source = encode(source)
88
@context = ::MiniRacer::Context.new
9+
@context.eval("delete this.console");
910
translate do
1011
@context.eval(source)
1112
end

lib/execjs/runtimes.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ module Runtimes
2424

2525
JavaScriptCore = ExternalRuntime.new(
2626
name: "JavaScriptCore",
27-
command: "/System/Library/Frameworks/JavaScriptCore.framework/Versions/A/Resources/jsc",
27+
command: [
28+
"/System/Library/Frameworks/JavaScriptCore.framework/Versions/Current/Helpers/jsc",
29+
"/System/Library/Frameworks/JavaScriptCore.framework/Versions/A/Resources/jsc",
30+
],
2831
runner_path: ExecJS.root + "/support/jsc_runner.js"
2932
)
3033

lib/execjs/support/node_runner.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,5 @@
2828
this.process = __process__;
2929
print(JSON.stringify(['err', '' + err, err.stack]));
3030
}
31+
__process__.exit(0);
3132
});

test/test_execjs.rb

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -104,21 +104,21 @@ def test_context_call_missing_function
104104
'"\\\\"' => "\\"
105105
}.each_with_index do |(input, output), index|
106106
define_method("test_exec_string_#{index}") do
107-
assert_equal output, ExecJS.exec("return #{input}")
107+
assert_output output, ExecJS.exec("return #{input}")
108108
end
109109

110110
define_method("test_eval_string_#{index}") do
111-
assert_equal output, ExecJS.eval(input)
111+
assert_output output, ExecJS.eval(input)
112112
end
113113

114114
define_method("test_compile_return_string_#{index}") do
115115
context = ExecJS.compile("var a = #{input};")
116-
assert_equal output, context.eval("a")
116+
assert_output output, context.eval("a")
117117
end
118118

119119
define_method("test_compile_call_string_#{index}") do
120120
context = ExecJS.compile("function a() { return #{input}; }")
121-
assert_equal output, context.call("a")
121+
assert_output output, context.call("a")
122122
end
123123
end
124124

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

147147
define_method("test_json_value_#{index}") do
148-
assert_equal value, JSON.parse(json_value, quirks_mode: true)
148+
assert_output value, JSON.parse(json_value, quirks_mode: true)
149149
end
150150

151151
define_method("test_exec_value_#{index}") do
152-
assert_equal value, ExecJS.exec("return #{json_value}")
152+
assert_output value, ExecJS.exec("return #{json_value}")
153153
end
154154

155155
define_method("test_eval_value_#{index}") do
156-
assert_equal value, ExecJS.eval("#{json_value}")
156+
assert_output value, ExecJS.eval("#{json_value}")
157157
end
158158

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

164164
define_method("test_call_value_#{index}") do
165165
context = ExecJS.compile("function id(obj) { return obj; }")
166-
assert_equal value, context.call("id", value)
166+
assert_output value, context.call("id", value)
167167
end
168168
end
169169

@@ -421,4 +421,14 @@ def test_uglify
421421
assert_equal "function foo(bar){return bar}",
422422
context.call("uglify", "function foo(bar) {\n return bar;\n}")
423423
end
424+
425+
private
426+
427+
def assert_output(expected, actual)
428+
if expected.nil?
429+
assert_nil actual
430+
else
431+
assert_equal expected, actual
432+
end
433+
end
424434
end

0 commit comments

Comments
 (0)