Skip to content

Commit 638f69c

Browse files
authored
Feature: add pkg/process (#21)
* Initial pkg/starlarkprocess * Replace skycfg with deterministic fork * Try fix flaky tests * More test fix for flakiness * revert use fork * Revert use of fork; try fixing up prototext output directly * Yes more flaky reduce efforts * Add
1 parent 3306e2a commit 638f69c

25 files changed

+329
-48
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ serve: build
2828
routeguide_proto_descriptor:
2929
bazel build //example/routeguide:routeguide_proto_descriptor
3030
cp -f bazel-bin/example/routeguide/routeguide_proto_descriptor.pb pkg/starlarkgrpc/
31+
cp -f bazel-bin/example/routeguide/routeguide_proto_descriptor.pb pkg/protodescriptorset/
3132

3233
.PHONY: plugin_proto_descriptor
3334
plugin_proto_descriptor:

cmd/grpcstar/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ go_binary(
6767

6868
go_test(
6969
name = "grpcstar_test",
70-
srcs = ["integration_test.go"],
70+
srcs = ["grpcstar_test.go"],
7171
data = glob(["testdata/**"]) + ["//example/routeguide:routeguide_proto_descriptor"],
7272
embed = [":grpcstar_lib"],
7373
deps = [
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"flag"
55
"os"
66
"path/filepath"
7+
"regexp"
78
"strings"
89
"testing"
910
"time"
@@ -93,6 +94,7 @@ func TestGoldens(t *testing.T) {
9394
if err != nil {
9495
t.Fatal("reading err file:", err)
9596
}
97+
gotErr = derandPrototext(t, gotErr)
9698

9799
if *update {
98100
if workspaceDir == "" {
@@ -126,3 +128,11 @@ func TestGoldens(t *testing.T) {
126128
})
127129
}
128130
}
131+
132+
func derandPrototext(t *testing.T, data []byte) []byte {
133+
in := string(data)
134+
re := regexp.MustCompile(`\s{2}([a-z]+):`)
135+
out := re.ReplaceAllString(in, " $1:")
136+
out = re.ReplaceAllString(out, " $1:")
137+
return []byte(out)
138+
}

cmd/grpcstar/testdata/headers.grpc.star.err

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[testdata/headers.grpc.star:22:10] server: GetFeature request message: <example.routeguide.Point latitude:2 longitude:1>
1+
[testdata/headers.grpc.star:22:10] server: GetFeature request message: <example.routeguide.Point latitude:2 longitude:1>
22
[testdata/headers.grpc.star:23:10] server: GetFeature request headers: [":authority", "content-type", "user-agent", "x-unary-request"]
33
[testdata/headers.grpc.star:24:10] server: GetFeature request header content-type: application/grpc
44
[testdata/headers.grpc.star:25:10] server: GetFeature request header user-agent: grpc-go/1.35.0
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
{"name":"point (1,2)"}
1+
{
2+
"name": "point (1,2)"
3+
}
24
{}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
def main(ctx):
2+
print(process)
3+
4+
print("run:", process.run)
5+
result = process.run(
6+
command = "pwd",
7+
)
8+
print("stdout (runfiles dir):", str(result.stdout).partition("grpcstar_test.runfiles")[2])
9+
print("stderr:", result.stderr)
10+
print("error:", result.error)
11+
print("exit_code:", result.exit_code)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[testdata/process.grpc.star:2:10] <module "process">
2+
[testdata/process.grpc.star:4:10] run: <built-in function process.run>
3+
[testdata/process.grpc.star:8:10] stdout (runfiles dir): /build_stack_grpc_starlark/cmd/grpcstar
4+
5+
[testdata/process.grpc.star:9:10] stderr:
6+
[testdata/process.grpc.star:10:10] error:
7+
[testdata/process.grpc.star:11:10] exit_code: 0

cmd/grpcstar/testdata/process.grpc.star.out

Whitespace-only changes.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[testdata/routeguide.grpc.star:92:10] GetFeature: <example.routeguide.Feature name:"point (1,2)">
22
[testdata/routeguide.grpc.star:104:14] ListFeatures: <example.routeguide.Feature name:"lo (1,2)">
33
[testdata/routeguide.grpc.star:104:14] ListFeatures: <example.routeguide.Feature name:"hi (1,4)">
4-
[testdata/routeguide.grpc.star:113:10] RecordRoute: <example.routeguide.RouteSummary point_count:2 distance:2 elapsed_time:10>
4+
[testdata/routeguide.grpc.star:113:10] RecordRoute: <example.routeguide.RouteSummary point_count:2 distance:2 elapsed_time:10>
55
[testdata/routeguide.grpc.star:124:14] RouteChat: <example.routeguide.RouteNote message:"A">
66
[testdata/routeguide.grpc.star:124:14] RouteChat: <example.routeguide.RouteNote message:"B">
Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
1-
{"name":"point (1,2)"}
2-
{"name":"lo (1,2)"}
3-
{"name":"hi (1,4)"}
4-
{"point_count":2, "distance":2, "elapsed_time":10}
5-
{"message":"A"}
6-
{"message":"B"}
1+
{
2+
"name": "point (1,2)"
3+
}
4+
{
5+
"name": "lo (1,2)"
6+
}
7+
{
8+
"name": "hi (1,4)"
9+
}
10+
{
11+
"point_count": 2,
12+
"distance": 2,
13+
"elapsed_time": 10
14+
}
15+
{
16+
"message": "A"
17+
}
18+
{
19+
"message": "B"
20+
}

0 commit comments

Comments
 (0)