forked from grafana/k6
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinternalize.patch
198 lines (182 loc) · 7.25 KB
/
internalize.patch
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
diff --git a/.github/workflows/tc39.yml b/.github/workflows/tc39.yml
index bd223f97a..e82421110 100644
--- a/.github/workflows/tc39.yml
+++ b/.github/workflows/tc39.yml
@@ -27,6 +27,6 @@ jobs:
- name: Run tests
run: |
set -x
- cd js/tc39
+ cd internal/js/tc39
sh checkout.sh
go test -timeout 1h
diff --git a/.github/workflows/wpt.yml b/.github/workflows/wpt.yml
index 1cd84215e..e2f14adbd 100644
--- a/.github/workflows/wpt.yml
+++ b/.github/workflows/wpt.yml
@@ -22,12 +22,12 @@ jobs:
- name: Run Streams Tests
run: |
set -x
- cd js/modules/k6/experimental/streams/tests
+ cd internal/js/modules/k6/experimental/streams/tests
sh checkout.sh
go test ../... -tags=wpt
- name: Run Webcrypto Tests
run: |
set -x
- cd js/modules/k6/webcrypto/tests
+ cd internal/js/modules/k6/webcrypto/tests
sh checkout.sh
go test ./... -tags=wpt
diff --git a/.gitignore b/.gitignore
index 3a37d8837..bdce1071f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,8 +2,8 @@
/k6.exe
/dist
/pkg-build
-/js/tc39/TestTC39
-/js/modules/k6/experimental/streams/tests/wpt
+/internal/js/tc39/TestTC39
+/internal/js/modules/k6/experimental/streams/tests/wpt
.vscode
*.sublime-workspace
@@ -36,4 +36,4 @@ script.js
/packaging/*.gpg
# web platform tests
-js/modules/k6/webcrypto/tests/wpt/
+/internal/js/modules/k6/webcrypto/tests/wpt/
diff --git a/cmd/execute.go b/cmd/execute.go
new file mode 100644
index 000000000..e84f839ba
--- /dev/null
+++ b/cmd/execute.go
@@ -0,0 +1,10 @@
+// Package cmd is here to provide a way for xk6 to build a binary with added extensions
+package cmd
+
+import "go.k6.io/k6/internal/cmd"
+
+// Execute exectues the k6 command
+// It only is exported here for backwards compatibility and the ability to use xk6 to build extended k6
+func Execute() {
+ cmd.Execute()
+}
diff --git a/cmd/tests/global_state.go b/cmd/tests/global_state.go
new file mode 100644
index 000000000..2b06bbf11
--- /dev/null
+++ b/cmd/tests/global_state.go
@@ -0,0 +1,17 @@
+// Package tests contains types needed for running integration tests that run k6 commands.
+package tests
+
+import (
+ "testing"
+
+ "go.k6.io/k6/internal/cmd/tests"
+)
+
+// GlobalTestState is a wrapper around GlobalState for use in tests.
+type GlobalTestState = tests.GlobalTestState
+
+// NewGlobalTestState returns an initialized GlobalTestState, mocking all
+// GlobalState fields for use in tests.
+func NewGlobalTestState(tb testing.TB) *GlobalTestState {
+ return tests.NewGlobalTestState(tb)
+}
diff --git a/internal/cmd/tests/cmd_run_grpc_test.go b/internal/cmd/tests/cmd_run_grpc_test.go
index 6783f4e11..a7399db44 100644
--- a/internal/cmd/tests/cmd_run_grpc_test.go
+++ b/internal/cmd/tests/cmd_run_grpc_test.go
@@ -12,7 +12,7 @@ import (
"github.com/stretchr/testify/require"
)
-const projectRootPath = "../../"
+const projectRootPath = "../../../"
// TestGRPCInputOutput runs same k6's scripts that we have in example folder
// it check that output contains/not contains cetane things
@@ -90,7 +90,7 @@ func TestGRPCInputOutput(t *testing.T) {
// Read the proto file from the testutils package
// it's same that we use in the examples
- proto, err := os.ReadFile(projectRootPath + "lib/testutils/grpcservice/route_guide.proto") //nolint:forbidigo
+ proto, err := os.ReadFile(projectRootPath + "internal/lib/testutils/grpcservice/route_guide.proto") //nolint:forbidigo
require.NoError(t, err)
for name, test := range tc {
diff --git a/internal/js/eventloop/eventloop_test.go b/internal/js/eventloop/eventloop_test.go
index 459960d7e..ed4f87877 100644
--- a/internal/js/eventloop/eventloop_test.go
+++ b/internal/js/eventloop/eventloop_test.go
@@ -199,7 +199,7 @@ func TestEventLoopRejectGoError(t *testing.T) {
return err
})
loop.WaitOnRegistered()
- require.EqualError(t, err, "Uncaught (in promise) GoError: some error\n\tat go.k6.io/k6/js/eventloop_test.TestEventLoopRejectGoError.func1 (native)\n\tat <eval>:1:31(2)\n")
+ require.EqualError(t, err, "Uncaught (in promise) GoError: some error\n\tat go.k6.io/k6/internal/js/eventloop_test.TestEventLoopRejectGoError.func1 (native)\n\tat <eval>:1:31(2)\n")
}
func TestEventLoopRejectThrow(t *testing.T) {
@@ -216,7 +216,7 @@ func TestEventLoopRejectThrow(t *testing.T) {
return err
})
loop.WaitOnRegistered()
- require.EqualError(t, err, "Uncaught (in promise) GoError: throw error\n\tat go.k6.io/k6/js/eventloop_test.TestEventLoopRejectThrow.func1 (native)\n\tat <eval>:1:31(2)\n")
+ require.EqualError(t, err, "Uncaught (in promise) GoError: throw error\n\tat go.k6.io/k6/internal/js/eventloop_test.TestEventLoopRejectThrow.func1 (native)\n\tat <eval>:1:31(2)\n")
}
func TestEventLoopAsyncAwait(t *testing.T) {
diff --git a/internal/js/modules/k6/webcrypto/cmd_run_test.go b/internal/js/modules/k6/webcrypto/cmd_run_test.go
index 68df57aaf..3ee0692fd 100644
--- a/internal/js/modules/k6/webcrypto/cmd_run_test.go
+++ b/internal/js/modules/k6/webcrypto/cmd_run_test.go
@@ -51,7 +51,7 @@ func TestExamplesInputOutput(t *testing.T) {
"level=error", // no error messages
}
- const examplesDir = "../../../../examples/webcrypto"
+ const examplesDir = "../../../../../examples/webcrypto"
// List of the directories containing the examples
// that we should run and check that they produce the expected output
diff --git a/lib/testutils/httpmultibin/nested_types/nested_types.proto b/internal/lib/testutils/httpmultibin/nested_types/nested_types.proto
similarity index 100%
rename from lib/testutils/httpmultibin/nested_types/nested_types.proto
rename to internal/lib/testutils/httpmultibin/nested_types/nested_types.proto
diff --git a/js/modules/require_impl.go b/js/modules/require_impl.go
index 5d10dd515..71098ec37 100644
--- a/js/modules/require_impl.go
+++ b/js/modules/require_impl.go
@@ -202,7 +202,7 @@ func getPreviousRequiringFile(vu VU) (string, error) {
for i, frame := range frames[1:] { // first one should be the current require
// TODO have this precalculated automatically
- if frame.FuncName() == "go.k6.io/k6/js.(*requireImpl).require-fm" {
+ if frame.FuncName() == "go.k6.io/k6/internal/js.(*requireImpl).require-fm" {
// we need to get the one *before* but as we skip the first one the index matches ;)
result := frames[i].SrcName()
if result == "file:///-" {
diff --git a/main.go b/main.go
index d2b2a33f8..84212739b 100644
--- a/main.go
+++ b/main.go
@@ -2,7 +2,7 @@
package main
import (
- "go.k6.io/k6/internal/cmd"
+ "go.k6.io/k6/cmd"
)
func main() {
"go.k6.io/k6/js/modulestest"
"github.com/stretchr/testify/require"
diff --git a/internal/js/modules/k6/webcrypto/tests/test_setup_test.go b/internal/js/modules/k6/webcrypto/tests/test_setup_test.go
index 42d42b9a9..2abab430d 100644
--- a/internal/js/modules/k6/webcrypto/tests/test_setup_test.go
+++ b/internal/js/modules/k6/webcrypto/tests/test_setup_test.go
@@ -5,9 +5,9 @@ package tests
import (
"testing"
- "go.k6.io/k6/js/compiler"
- k6encoding "go.k6.io/k6/js/modules/k6/encoding"
- "go.k6.io/k6/js/modules/k6/webcrypto"
+ "go.k6.io/k6/internal/js/compiler"
+ k6encoding "go.k6.io/k6/internal/js/modules/k6/encoding"
+ "go.k6.io/k6/internal/js/modules/k6/webcrypto"
"go.k6.io/k6/js/modulestest"
"github.com/stretchr/testify/require"