THRIFT-5564: Add nodejs tests to github actions (#3082)
These tests exist, but don't currently run on github actions. This adds a new job to run these.
This also fixes the regression in the tests caused by https://github.com/apache/thrift/pull/3014.
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 1e953b6..90eb7f3 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -519,6 +519,32 @@
- name: Run make check for python
run: make -C lib/py check
+ lib-nodejs:
+ needs: compiler
+ runs-on: ubuntu-24.04
+ steps:
+ - uses: actions/checkout@v4
+
+ - name: Run bootstrap
+ run: ./bootstrap.sh
+
+ - name: Run configure
+ run: |
+ ./configure $(echo $CONFIG_ARGS_FOR_LIBS | sed 's/without-nodejs/with-nodejs/')
+
+ - uses: actions/download-artifact@v4
+ with:
+ name: thrift-compiler
+ path: compiler/cpp
+
+ - name: Run thrift-compiler
+ run: |
+ chmod a+x compiler/cpp/thrift
+ compiler/cpp/thrift -version
+
+ - name: Run tests
+ run: make -C lib/nodejs check
+
cross-test:
needs:
- lib-java-kotlin
diff --git a/lib/nodejs/lib/thrift/thrift.js b/lib/nodejs/lib/thrift/thrift.js
index f728eac..3a693f6 100644
--- a/lib/nodejs/lib/thrift/thrift.js
+++ b/lib/nodejs/lib/thrift/thrift.js
@@ -86,7 +86,7 @@
};
util.inherits(TApplicationException, TException);
-TApplicationException.prototype.read = function(input) {
+TApplicationException.prototype[Symbol.for("read")] = TApplicationException.prototype.read = function(input) {
var ftype;
var ret = input.readStructBegin('TApplicationException');
@@ -121,7 +121,7 @@
input.readStructEnd();
};
-TApplicationException.prototype.write = function(output){
+TApplicationException.prototype[Symbol.for("write")] = TApplicationException.prototype.write = function(output){
output.writeStructBegin('TApplicationException');
if (this.message) {
diff --git a/lib/nodejs/test/deep-constructor.test.js b/lib/nodejs/test/deep-constructor.test.js
index 504dacf..a91ddb1 100644
--- a/lib/nodejs/test/deep-constructor.test.js
+++ b/lib/nodejs/test/deep-constructor.test.js
@@ -28,7 +28,7 @@
buff = msg;
});
const prot = new thrift.TBinaryProtocol(transport);
- data.write(prot);
+ data[Symbol.for("write")](prot);
prot.flush();
return buff;
}
@@ -37,7 +37,7 @@
const t = new thrift.TFramedTransport(serialized);
const p = new thrift.TBinaryProtocol(t);
const data = new type();
- data.read(p);
+ data[Symbol.for("read")](p);
return data;
}
@@ -48,7 +48,7 @@
});
const protocol = new thrift.TJSONProtocol(transport);
protocol.writeMessageBegin("", 0, 0);
- data.write(protocol);
+ data[Symbol.for("write")](protocol);
protocol.writeMessageEnd();
protocol.flush();
return buff;
@@ -59,7 +59,7 @@
const protocol = new thrift.TJSONProtocol(transport);
protocol.readMessageBegin();
const data = new type();
- data.read(protocol);
+ data[Symbol.for("read")](protocol);
protocol.readMessageEnd();
return data;
}