CI: Dockerized language port tests (#5066)

This runs a script in TravisCI that executes a bunch of small Docker image
scripts to test the language ports in isolated environments. This allows us to
test multiple language versions with little additional complexity.

Covers:

+ Java OpenJDK 10.0.2
+ Java OpenJDK 11.0.1
+ Node 10.13.0
+ Node 11.2.0
+ Python CPython 2.7.15
+ Python CPython 3.7.1
+ Rust 1.30.1
This commit is contained in:
Robert
2018-11-29 22:03:06 -08:00
committed by GitHub
parent b378b8eb69
commit 79cd55bd3a
15 changed files with 142 additions and 7 deletions

View File

@@ -0,0 +1,9 @@
FROM debian:9.6-slim as base
RUN apt -qq update >/dev/null
RUN apt -qq install -y cmake make build-essential >/dev/null
FROM base
WORKDIR /code
ADD . .
RUN cmake -G "Unix Makefiles"
RUN make flatc
RUN ls flatc

View File

@@ -0,0 +1,7 @@
FROM pypy:2-6.0.0-slim as base
WORKDIR /code
ADD . .
RUN cp flatc_debian_stretch flatc
WORKDIR /code/tests
RUN pypy --version
RUN ./PythonTest.sh

View File

@@ -0,0 +1,7 @@
FROM pypy:3-6.0.0-slim as base
WORKDIR /code
ADD . .
RUN cp flatc_debian_stretch flatc
WORKDIR /code/tests
RUN pypy --version
RUN ./PythonTest.sh

View File

@@ -0,0 +1,7 @@
FROM openjdk:10.0.2-jdk-slim-sid as base
WORKDIR /code
ADD . .
RUN cp flatc_debian_stretch flatc
WORKDIR /code/tests
RUN java -version
RUN ./JavaTest.sh

View File

@@ -0,0 +1,7 @@
FROM openjdk:11.0.1-jdk-slim-sid as base
WORKDIR /code
ADD . .
RUN cp flatc_debian_stretch flatc
WORKDIR /code/tests
RUN java -version
RUN ./JavaTest.sh

View File

@@ -0,0 +1,8 @@
FROM node:10.13.0-stretch as base
WORKDIR /code
ADD . .
RUN cp flatc_debian_stretch flatc
WORKDIR /code/tests
RUN node --version
RUN ../flatc -b -I include_test monster_test.fbs unicode_test.json
RUN node JavaScriptTest ./monster_test_generated

View File

@@ -0,0 +1,8 @@
FROM node:11.2.0-stretch as base
WORKDIR /code
ADD . .
RUN cp flatc_debian_stretch flatc
WORKDIR /code/tests
RUN node --version
RUN ../flatc -b -I include_test monster_test.fbs unicode_test.json
RUN node JavaScriptTest ./monster_test_generated

View File

@@ -0,0 +1,7 @@
FROM python:2.7.15-slim-stretch as base
WORKDIR /code
ADD . .
RUN cp flatc_debian_stretch flatc
WORKDIR /code/tests
RUN python --version
RUN ./PythonTest.sh

View File

@@ -0,0 +1,7 @@
FROM python:3.7.1-slim-stretch as base
WORKDIR /code
ADD . .
RUN cp flatc_debian_stretch flatc
WORKDIR /code/tests
RUN python --version
RUN ./PythonTest.sh

View File

@@ -0,0 +1,7 @@
FROM rust:1.30.1-slim-stretch as base
WORKDIR /code
ADD . .
RUN cp flatc_debian_stretch flatc
WORKDIR /code/tests
RUN rustc --version
RUN ./RustTest.sh

View File

@@ -246,7 +246,7 @@ mod lifetime_correctness {
#[test]
fn table_get_field_from_static_buffer_1() {
let buf = load_file("../monsterdata_test.mon");
let buf = load_file("../monsterdata_test.mon").expect("missing monsterdata_test.mon");
// create 'static slice
let slice: &[u8] = &buf;
let slice: &'static [u8] = unsafe { mem::transmute(slice) };
@@ -268,7 +268,7 @@ mod lifetime_correctness {
#[test]
fn table_object_self_lifetime_in_closure() {
// This test is designed to ensure that lifetimes for temporary intermediate tables aren't inflated beyond where the need to be.
let buf = load_file("../monsterdata_test.mon");
let buf = load_file("../monsterdata_test.mon").expect("missing monsterdata_test.mon");
let monster = my_game::example::get_root_as_monster(&buf);
let enemy: Option<my_game::example::Monster> = monster.enemy();
// This line won't compile if "self" is required to live for the lifetime of buf above as the borrow disappears at the end of the closure.
@@ -1414,17 +1414,27 @@ mod read_examples_from_other_language_ports {
#[test]
fn gold_cpp_example_data_is_accessible_and_correct() {
let buf = load_file("../monsterdata_test.mon");
let buf = load_file("../monsterdata_test.mon").expect("missing monsterdata_test.mon");
serialized_example_is_accessible_and_correct(&buf[..], true, false).unwrap();
}
#[test]
fn java_wire_example_data_is_accessible_and_correct() {
let buf = load_file("../monsterdata_java_wire.mon");
if buf.is_err() {
println!("skipping java wire test because it is not present");
return;
}
let buf = buf.unwrap();
serialized_example_is_accessible_and_correct(&buf[..], true, false).unwrap();
}
#[test]
fn java_wire_size_prefixed_example_data_is_accessible_and_correct() {
let buf = load_file("../monsterdata_java_wire_sp.mon");
if buf.is_err() {
println!("skipping java wire test because it is not present");
return;
}
let buf = buf.unwrap();
serialized_example_is_accessible_and_correct(&buf[..], true, true).unwrap();
}
}
@@ -2676,10 +2686,10 @@ fn write_example_wire_data_to_file() {
f.write_all(b.finished_data()).unwrap();
}
fn load_file(filename: &str) -> Vec<u8> {
fn load_file(filename: &str) -> Result<Vec<u8>, std::io::Error> {
use std::io::Read;
let mut f = std::fs::File::open(filename).expect("file does not exist");
let mut f = std::fs::File::open(filename)?;
let mut buf = Vec::new();
f.read_to_end(&mut buf).expect("file reading failed");
buf
f.read_to_end(&mut buf)?;
Ok(buf)
}