Skip to content

Commit

Permalink
Merge pull request #1904 from loadimpact/updateGoja
Browse files Browse the repository at this point in the history
update goja to latest master
  • Loading branch information
mstoykov authored Mar 22, 2021
2 parents 9d973f5 + ef479a8 commit 60d5a05
Show file tree
Hide file tree
Showing 29 changed files with 6,858 additions and 5,425 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ require (
github.com/andybalholm/cascadia v1.0.0 // indirect
github.com/daaku/go.zipexe v0.0.0-20150329023125-a5fe2436ffcb // indirect
github.com/dlclark/regexp2 v1.4.1-0.20201116162257-a2a8dda75c91 // indirect
github.com/dop251/goja v0.0.0-20210216182323-60bc6ebb9fc1
github.com/dop251/goja v0.0.0-20210317175251-bb14c2267b76
github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4
github.com/eapache/go-resiliency v1.1.0 // indirect
github.com/eapache/go-xerial-snappy v0.0.0-20160609142408-bb955e01b934 // indirect
Expand Down
7 changes: 2 additions & 5 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dlclark/regexp2 v1.4.1-0.20201116162257-a2a8dda75c91 h1:Izz0+t1Z5nI16/II7vuEo/nHjodOg0p7+OiDpjX5t1E=
github.com/dlclark/regexp2 v1.4.1-0.20201116162257-a2a8dda75c91/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc=
github.com/dop251/goja v0.0.0-20210216182323-60bc6ebb9fc1 h1:2Xfv4vHdBWlxJLq8BU4I28a+DsKsyi7Rqjrfo4qp9L4=
github.com/dop251/goja v0.0.0-20210216182323-60bc6ebb9fc1/go.mod h1:Mw6PkjjMXWbTj+nnj4s3QPXq1jaT0s5pC0iFD4+BOAA=
github.com/dop251/goja v0.0.0-20210317175251-bb14c2267b76 h1:da/WKkWtBnwAC/DPGZQ7W2pKVEHGEyFU1u40L73DJN8=
github.com/dop251/goja v0.0.0-20210317175251-bb14c2267b76/go.mod h1:Mw6PkjjMXWbTj+nnj4s3QPXq1jaT0s5pC0iFD4+BOAA=
github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4 h1:qk/FSDDxo05wdJH28W+p5yivv7LuLYLRXPPD8KQCtZs=
github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/eapache/go-resiliency v1.1.0 h1:1NtRmCAqadE2FN4ZcN6g90TP3uk8cg9rn9eNK2197aU=
Expand All @@ -43,7 +43,6 @@ github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1m
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/fatih/color v1.5.0 h1:vBh+kQp8lg9XPr56u1CPrWjFXtdphMoGWVHr9/1c+A0=
github.com/fatih/color v1.5.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
Expand Down Expand Up @@ -89,7 +88,6 @@ github.com/gorilla/mux v1.6.1 h1:KOwqsTYZdeuMacU7CxjMNYEKeBvLbxW+psodrbcEa3A=
github.com/gorilla/mux v1.6.1/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
Expand Down Expand Up @@ -227,7 +225,6 @@ golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200519105757-fe76b779f299 h1:DYfZAGf2WMFjMxbgTjaC+2HC7NkNAQs+6Q8b9WEB/F4=
golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f h1:+Nyd8tzPX9R7BWHguqsrbFdRx3WQ/1ib8I44HXV5yTA=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
Expand Down
2 changes: 1 addition & 1 deletion js/bundle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ func TestNewBundle(t *testing.T) {
{
"Promise", "base",
`module.exports.default = function() {}; new Promise(function(resolve, reject){});`,
"ReferenceError: Promise is not defined at file:///script.js:1:45(5)",
"ReferenceError: Promise is not defined at file:///script.js:1:45(4)",
},
}

Expand Down
6 changes: 3 additions & 3 deletions js/compiler/compiler.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ var (
"transform-es2015-literals",
"transform-es2015-function-name",
[]interface{}{"transform-es2015-arrow-functions", map[string]interface{}{"spec": false}},
"transform-es2015-block-scoped-functions",
// "transform-es2015-block-scoped-functions", // in goja
[]interface{}{"transform-es2015-classes", map[string]interface{}{"loose": false}},
"transform-es2015-object-super",
// "transform-es2015-shorthand-properties", // in goja
Expand All @@ -53,11 +53,11 @@ var (
// "transform-es2015-for-of", // in goja
// "transform-es2015-sticky-regex", // in goja
// "transform-es2015-unicode-regex", // in goja
"check-es2015-constants",
// "check-es2015-constants", // in goja
[]interface{}{"transform-es2015-spread", map[string]interface{}{"loose": false}},
"transform-es2015-parameters",
[]interface{}{"transform-es2015-destructuring", map[string]interface{}{"loose": false}},
"transform-es2015-block-scoping", // let/const which particularly slow on big inputs
// "transform-es2015-block-scoping", // in goja
// "transform-es2015-typeof-symbol", // in goja
// all the other module plugins are just dropped
[]interface{}{"transform-es2015-modules-commonjs", map[string]interface{}{"loose": false}},
Expand Down
2 changes: 1 addition & 1 deletion js/compiler/compiler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func TestTransform(t *testing.T) {
` return a + b;`,
`};`,
``,
`var res = add(1, 2);`,
`let res = add(1, 2);`,
}, "\n"), src)
// assert.Equal(t, 3, srcmap.Version)
// assert.Equal(t, "test.js", srcmap.File)
Expand Down
32 changes: 21 additions & 11 deletions js/modules/k6/http/request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1184,22 +1184,25 @@ func TestRequestAndBatch(t *testing.T) {
})
t.Run("GET", func(t *testing.T) {
_, err := rt.RunString(sr(`
var reqs = [
{
let reqs = [
["GET", "HTTPBIN_URL/"],
["GET", "HTTPBIN_IP_URL/"],
];
var res = http.batch(reqs);
let res = http.batch(reqs);
for (var key in res) {
if (res[key].status != 200) { throw new Error("wrong status: " + res[key].status); }
if (res[key].url != reqs[key][1]) { throw new Error("wrong url: " + res[key].url); }
}`))
}
}`))
require.NoError(t, err)
bufSamples := stats.GetBufferedSamples(samples)
assertRequestMetricsEmitted(t, bufSamples, "GET", sr("HTTPBIN_URL/"), "", 200, "")
assertRequestMetricsEmitted(t, bufSamples, "GET", sr("HTTPBIN_IP_URL/"), "", 200, "")

t.Run("Tagged", func(t *testing.T) {
_, err := runES6String(t, rt, sr(`
{
let fragment = "get";
let reqs = [
["GET", http.url`+"`"+`HTTPBIN_URL/${fragment}`+"`"+`],
Expand All @@ -1209,7 +1212,8 @@ func TestRequestAndBatch(t *testing.T) {
for (var key in res) {
if (res[key].status != 200) { throw new Error("wrong status: " + key + ": " + res[key].status); }
if (res[key].url != reqs[key][1].url) { throw new Error("wrong url: " + key + ": " + res[key].url + " != " + reqs[key][1].url); }
}`))
}
}`))
assert.NoError(t, err)
bufSamples := stats.GetBufferedSamples(samples)
assertRequestMetricsEmitted(t, bufSamples, "GET", sr("HTTPBIN_URL/get"), sr("HTTPBIN_URL/${}"), 200, "")
Expand All @@ -1218,22 +1222,25 @@ func TestRequestAndBatch(t *testing.T) {

t.Run("Shorthand", func(t *testing.T) {
_, err := rt.RunString(sr(`
var reqs = [
{
let reqs = [
"HTTPBIN_URL/",
"HTTPBIN_IP_URL/",
];
var res = http.batch(reqs);
let res = http.batch(reqs);
for (var key in res) {
if (res[key].status != 200) { throw new Error("wrong status: " + key + ": " + res[key].status); }
if (res[key].url != reqs[key]) { throw new Error("wrong url: " + key + ": " + res[key].url); }
}`))
}
}`))
assert.NoError(t, err)
bufSamples := stats.GetBufferedSamples(samples)
assertRequestMetricsEmitted(t, bufSamples, "GET", sr("HTTPBIN_URL/"), "", 200, "")
assertRequestMetricsEmitted(t, bufSamples, "GET", sr("HTTPBIN_IP_URL/"), "", 200, "")

t.Run("Tagged", func(t *testing.T) {
_, err := runES6String(t, rt, sr(`
{
let fragment = "get";
let reqs = [
http.url`+"`"+`HTTPBIN_URL/${fragment}`+"`"+`,
Expand All @@ -1243,7 +1250,8 @@ func TestRequestAndBatch(t *testing.T) {
for (var key in res) {
if (res[key].status != 200) { throw new Error("wrong status: " + key + ": " + res[key].status); }
if (res[key].url != reqs[key].url) { throw new Error("wrong url: " + key + ": " + res[key].url + " != " + reqs[key].url); }
}`))
}
}`))
assert.NoError(t, err)
bufSamples := stats.GetBufferedSamples(samples)
assertRequestMetricsEmitted(t, bufSamples, "GET", sr("HTTPBIN_URL/get"), sr("HTTPBIN_URL/${}"), 200, "")
Expand All @@ -1253,15 +1261,17 @@ func TestRequestAndBatch(t *testing.T) {

t.Run("ObjectForm", func(t *testing.T) {
_, err := rt.RunString(sr(`
var reqs = [
{
let reqs = [
{ method: "GET", url: "HTTPBIN_URL/" },
{ url: "HTTPBIN_IP_URL/", method: "GET"},
];
var res = http.batch(reqs);
let res = http.batch(reqs);
for (var key in res) {
if (res[key].status != 200) { throw new Error("wrong status: " + key + ": " + res[key].status); }
if (res[key].url != reqs[key].url) { throw new Error("wrong url: " + key + ": " + res[key].url + " != " + reqs[key].url); }
}`))
}
}`))
assert.NoError(t, err)
bufSamples := stats.GetBufferedSamples(samples)
assertRequestMetricsEmitted(t, bufSamples, "GET", sr("HTTPBIN_URL/"), "", 200, "")
Expand Down
4 changes: 3 additions & 1 deletion js/runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1819,7 +1819,9 @@ func TestVUPanic(t *testing.T) {
require.Len(t, entries, 1)
assert.Equal(t, logrus.ErrorLevel, entries[0].Level)
require.True(t, strings.HasPrefix(entries[0].Message, "panic: here we panic"))
require.True(t, strings.HasSuffix(entries[0].Message, "Goja stack:\nfile:///script.js:3:4(12)"))
// broken since goja@f3cfc97811c0b4d8337902c3e42fb2371ba1d524 see
// https://github.com/dop251/goja/issues/179#issuecomment-783572020
// require.True(t, strings.HasSuffix(entries[0].Message, "Goja stack:\nfile:///script.js:3:4(12)"))

err = vu.RunOnce()
assert.NoError(t, err)
Expand Down
Loading

0 comments on commit 60d5a05

Please sign in to comment.