From ee4f65be64c8e3bdebc49443612aa2308e7cf6f3 Mon Sep 17 00:00:00 2001 From: Paul Cody Johnston Date: Tue, 31 Oct 2017 16:28:41 -0600 Subject: [PATCH 1/2] Add test example for protobuf.js --- Makefile | 5 ++++- tests/protobuf.js/BUILD | 18 ++++++++++++++++++ tests/protobuf.js/WORKSPACE | 15 +++++++++++++++ tests/protobuf.js/app.js | 3 +++ tests/protobuf.js/protobuf_test.sh | 7 +++++++ 5 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 tests/protobuf.js/BUILD create mode 100644 tests/protobuf.js/WORKSPACE create mode 100644 tests/protobuf.js/app.js create mode 100755 tests/protobuf.js/protobuf_test.sh diff --git a/Makefile b/Makefile index 6dd9581..597d3bf 100644 --- a/Makefile +++ b/Makefile @@ -19,4 +19,7 @@ test_webpack: test_mocha: (cd tests/mocha && bazel test //...) -test_all: test_helloworld test_lyrics test_express test_namespace test_typescript test_webpack test_mocha +test_protobuf_js: + (cd tests/protobuf.js && bazel test //...) + +test_all: test_helloworld test_lyrics test_express test_namespace test_typescript test_webpack test_mocha test_protobuf_js diff --git a/tests/protobuf.js/BUILD b/tests/protobuf.js/BUILD new file mode 100644 index 0000000..13e6a79 --- /dev/null +++ b/tests/protobuf.js/BUILD @@ -0,0 +1,18 @@ +package(default_visibility = ["//visibility:public"]) + +load("@org_pubref_rules_node//node:rules.bzl", "node_binary") + +node_binary( + name = "app", + main = "app.js", + deps = [ + "@yarn_modules//:protobuf.js", + ], +) + +sh_test( + name = "protobuf_test", + size = "small", + srcs = ["protobuf_test.sh"], + data = [":app"], +) diff --git a/tests/protobuf.js/WORKSPACE b/tests/protobuf.js/WORKSPACE new file mode 100644 index 0000000..b21de8b --- /dev/null +++ b/tests/protobuf.js/WORKSPACE @@ -0,0 +1,15 @@ +local_repository( + name = "org_pubref_rules_node", + path = "../..", +) + +load("@org_pubref_rules_node//node:rules.bzl", "node_repositories", "yarn_modules") + +node_repositories() + +yarn_modules( + name = "yarn_modules", + deps = { + "protobuf.js": "1.1.2", + } +) diff --git a/tests/protobuf.js/app.js b/tests/protobuf.js/app.js new file mode 100644 index 0000000..aaecc78 --- /dev/null +++ b/tests/protobuf.js/app.js @@ -0,0 +1,3 @@ +const protobuf = require('protobuf.js'); + +console.log('SUCCESS'); diff --git a/tests/protobuf.js/protobuf_test.sh b/tests/protobuf.js/protobuf_test.sh new file mode 100755 index 0000000..903fafa --- /dev/null +++ b/tests/protobuf.js/protobuf_test.sh @@ -0,0 +1,7 @@ +set -euo pipefail + +if ./app | grep -q 'SUCCESS'; then + echo "PASS" +else + exit 1 +fi From dae040d03faddc10503f9a8a8fd1d60f2733b52e Mon Sep 17 00:00:00 2001 From: Rohan Agarwal Date: Tue, 31 Oct 2017 23:59:40 -0400 Subject: [PATCH 2/2] Use correct protobufjs library --- tests/protobuf.js/BUILD | 2 +- tests/protobuf.js/WORKSPACE | 2 +- tests/protobuf.js/app.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/protobuf.js/BUILD b/tests/protobuf.js/BUILD index 13e6a79..72dca36 100644 --- a/tests/protobuf.js/BUILD +++ b/tests/protobuf.js/BUILD @@ -6,7 +6,7 @@ node_binary( name = "app", main = "app.js", deps = [ - "@yarn_modules//:protobuf.js", + "@yarn_modules//:protobufjs", ], ) diff --git a/tests/protobuf.js/WORKSPACE b/tests/protobuf.js/WORKSPACE index b21de8b..456af45 100644 --- a/tests/protobuf.js/WORKSPACE +++ b/tests/protobuf.js/WORKSPACE @@ -10,6 +10,6 @@ node_repositories() yarn_modules( name = "yarn_modules", deps = { - "protobuf.js": "1.1.2", + "protobufjs": "6.8.0", } ) diff --git a/tests/protobuf.js/app.js b/tests/protobuf.js/app.js index aaecc78..2d048f5 100644 --- a/tests/protobuf.js/app.js +++ b/tests/protobuf.js/app.js @@ -1,3 +1,3 @@ -const protobuf = require('protobuf.js'); +const protobuf = require('protobufjs'); console.log('SUCCESS');