From 12517a0d1eac5f3ccf2f9c6789d590575d0100b6 Mon Sep 17 00:00:00 2001 From: Scott Kyle Date: Thu, 21 Apr 2016 17:45:17 -0700 Subject: [PATCH] Add ability to run Node tests on Linux It uses the Android ExternalCommitHelper implementation. The Dockerfile requires that you have a static library build of core for Linux with PIC enabled. --- .dockerignore | 26 ++++++++++++++ Dockerfile | 34 ++++++++++++++++++ scripts/download-core.sh | 4 ++- src/RealmJS.xcodeproj/project.pbxproj | 36 +++++++++++++++++++ src/node/binding.gyp | 26 ++++++++++++-- .../src/impl/external_commit_helper.hpp | 2 +- .../src/impl/transact_log_handler.cpp | 2 +- 7 files changed, 124 insertions(+), 6 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..c2091bd9 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,26 @@ +**/*.orig +**/build/ +**/node_modules/ + +core* + +.git/ +android/ +docs/ +examples/ +react-native/ +vendor/ + +src/android/ +src/ios/ + +src/object-store/**/*.ninja +src/object-store/**/.ninja* +src/object-store/**/cmake_install.cmake +src/object-store/**/CMakeFiles/ +src/object-store/**/Makefile +src/object-store/src/librealm-object-store.* +src/object-store/tests/tests + +tests/ios/ +tests/react-test-app/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..0e975e97 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,34 @@ +FROM node:6 + +# Make debugging quicker. +RUN apt-get update && apt-get install -y gdb vim + +# Add non-root user. +RUN useradd -ms /bin/bash user + +# Make our workspace directory and work from there. +RUN mkdir -p /usr/src/app +WORKDIR /usr/src/app + +# Get the node_modules setup before anything else. +COPY package.json . +RUN npm install + +# Copy only what we need to build. +ADD realm-core-linux-0.100.3.tar.gz core/ +COPY src/ src/ + +# Build the Debug version of the module. +RUN src/node/build-node.sh Debug + +# Copy everything else needed to run tests. +COPY lib/ lib/ +COPY scripts/ scripts/ +COPY tests/ tests/ + +# Switch to the non-root user. +RUN chown -R user . +USER user + +# Default to running the Node tests +CMD ["node", "tests"] diff --git a/scripts/download-core.sh b/scripts/download-core.sh index b3cb2dbc..b32a11d3 100755 --- a/scripts/download-core.sh +++ b/scripts/download-core.sh @@ -51,7 +51,9 @@ if [[ $1 = "--version" ]]; then exit 0 fi -if [ ! -e core ]; then +if [ "$(uname)" != 'Darwin' ]; then + echo "Skipped downloading core on a non-Apple platform." +elif [ ! -e core ]; then download_core elif [ -d core -a -d ../realm-core -a ! -L core ]; then # Allow newer versions than expected for local builds as testing diff --git a/src/RealmJS.xcodeproj/project.pbxproj b/src/RealmJS.xcodeproj/project.pbxproj index d5efe39a..7ebd2e4b 100644 --- a/src/RealmJS.xcodeproj/project.pbxproj +++ b/src/RealmJS.xcodeproj/project.pbxproj @@ -50,6 +50,9 @@ F620F0581CB766DA0082977B /* node_init.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F620F0571CB766DA0082977B /* node_init.cpp */; }; F620F0751CB9F60C0082977B /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F620F0741CB9F60C0082977B /* CoreFoundation.framework */; }; F63117F01CEB0D5F00ECB2DE /* weak_realm_notifier.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F63117EE1CEB0D5900ECB2DE /* weak_realm_notifier.cpp */; }; + F63118471CEBA7B700ECB2DE /* external_commit_helper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F63118431CEBA7B700ECB2DE /* external_commit_helper.cpp */; }; + F63118481CEBA7B700ECB2DE /* weak_realm_notifier.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F63118451CEBA7B700ECB2DE /* weak_realm_notifier.cpp */; }; + F631184D1CEBA7D800ECB2DE /* external_commit_helper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F631184A1CEBA7D800ECB2DE /* external_commit_helper.cpp */; }; F63FF2C61C12469E00B3B8E0 /* jsc_init.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 029048011C0428DF00ABDED4 /* jsc_init.cpp */; }; F63FF2C91C12469E00B3B8E0 /* js_realm.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 029048071C0428DF00ABDED4 /* js_realm.cpp */; }; F63FF2CD1C12469E00B3B8E0 /* rpc.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0290480F1C0428DF00ABDED4 /* rpc.cpp */; }; @@ -197,6 +200,13 @@ F62BF8FB1CAC71780022BCDC /* libRealmNode.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = libRealmNode.dylib; sourceTree = BUILT_PRODUCTS_DIR; }; F63117EE1CEB0D5900ECB2DE /* weak_realm_notifier.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = weak_realm_notifier.cpp; sourceTree = ""; }; F63117EF1CEB0D5900ECB2DE /* weak_realm_notifier.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = weak_realm_notifier.hpp; sourceTree = ""; }; + F63118431CEBA7B700ECB2DE /* external_commit_helper.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = external_commit_helper.cpp; sourceTree = ""; }; + F63118441CEBA7B700ECB2DE /* external_commit_helper.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = external_commit_helper.hpp; sourceTree = ""; }; + F63118451CEBA7B700ECB2DE /* weak_realm_notifier.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = weak_realm_notifier.cpp; sourceTree = ""; }; + F63118461CEBA7B700ECB2DE /* weak_realm_notifier.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = weak_realm_notifier.hpp; sourceTree = ""; }; + F631184A1CEBA7D800ECB2DE /* external_commit_helper.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = external_commit_helper.cpp; sourceTree = ""; }; + F631184B1CEBA7D800ECB2DE /* external_commit_helper.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = external_commit_helper.hpp; sourceTree = ""; }; + F631184C1CEBA7D800ECB2DE /* weak_realm_notifier.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = weak_realm_notifier.hpp; sourceTree = ""; }; F63FF2B11C1241E500B3B8E0 /* libRealmJS.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRealmJS.a; sourceTree = BUILT_PRODUCTS_DIR; }; F63FF2F01C16405C00B3B8E0 /* libGCDWebServers.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libGCDWebServers.a; sourceTree = BUILT_PRODUCTS_DIR; }; F63FF2FD1C1642BB00B3B8E0 /* GCDWebServer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GCDWebServer.h; sourceTree = ""; }; @@ -442,7 +452,9 @@ F63117EA1CEB0BFA00ECB2DE /* impl */ = { isa = PBXGroup; children = ( + F63118421CEBA7A100ECB2DE /* android */, F63117EB1CEB0C1B00ECB2DE /* apple */, + F63118491CEBA7BD00ECB2DE /* generic */, F63117ED1CEB0CC600ECB2DE /* node */, 02414B991CE6AAEF00A8669F /* collection_change_builder.cpp */, 02414B9A1CE6AAEF00A8669F /* collection_change_builder.hpp */, @@ -496,6 +508,27 @@ path = node; sourceTree = ""; }; + F63118421CEBA7A100ECB2DE /* android */ = { + isa = PBXGroup; + children = ( + F63118431CEBA7B700ECB2DE /* external_commit_helper.cpp */, + F63118441CEBA7B700ECB2DE /* external_commit_helper.hpp */, + F63118451CEBA7B700ECB2DE /* weak_realm_notifier.cpp */, + F63118461CEBA7B700ECB2DE /* weak_realm_notifier.hpp */, + ); + path = android; + sourceTree = ""; + }; + F63118491CEBA7BD00ECB2DE /* generic */ = { + isa = PBXGroup; + children = ( + F631184A1CEBA7D800ECB2DE /* external_commit_helper.cpp */, + F631184B1CEBA7D800ECB2DE /* external_commit_helper.hpp */, + F631184C1CEBA7D800ECB2DE /* weak_realm_notifier.hpp */, + ); + path = generic; + sourceTree = ""; + }; F63FF2FB1C1642BB00B3B8E0 /* GCDWebServer */ = { isa = PBXGroup; children = ( @@ -846,6 +879,7 @@ F63FF31C1C1642BB00B3B8E0 /* GCDWebServerConnection.m in Sources */, F63FF3201C1642BB00B3B8E0 /* GCDWebServerDataRequest.m in Sources */, F63FF3221C1642BB00B3B8E0 /* GCDWebServerMultiPartFormRequest.m in Sources */, + F631184D1CEBA7D800ECB2DE /* external_commit_helper.cpp in Sources */, F63FF3211C1642BB00B3B8E0 /* GCDWebServerFileRequest.m in Sources */, F63FF31F1C1642BB00B3B8E0 /* GCDWebServerResponse.m in Sources */, F63FF3261C1642BB00B3B8E0 /* GCDWebServerFileResponse.m in Sources */, @@ -853,7 +887,9 @@ F63FF3241C1642BB00B3B8E0 /* GCDWebServerDataResponse.m in Sources */, F63FF31B1C1642BB00B3B8E0 /* GCDWebServer.m in Sources */, F63FF31D1C1642BB00B3B8E0 /* GCDWebServerFunctions.m in Sources */, + F63118481CEBA7B700ECB2DE /* weak_realm_notifier.cpp in Sources */, F63FF3251C1642BB00B3B8E0 /* GCDWebServerErrorResponse.m in Sources */, + F63118471CEBA7B700ECB2DE /* external_commit_helper.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/src/node/binding.gyp b/src/node/binding.gyp index bc6f65f4..4eead491 100644 --- a/src/node/binding.gyp +++ b/src/node/binding.gyp @@ -20,7 +20,6 @@ "../object-store/src/impl/realm_coordinator.cpp", "../object-store/src/impl/results_notifier.cpp", "../object-store/src/impl/transact_log_handler.cpp", - "../object-store/src/impl/apple/external_commit_helper.cpp", "../object-store/src/impl/node/weak_realm_notifier.cpp", "../object-store/src/parser/parser.cpp", "../object-store/src/parser/query_builder.cpp", @@ -44,15 +43,36 @@ "REALM_HAVE_CONFIG", "REALM_PLATFORM_NODE=1" ], - "cflags_cc": ["-fexceptions", "-frtti", "-std=c++14"], + "cflags_cc": [ + "-fexceptions", + "-frtti", + "-std=c++14", + "-Wno-missing-field-initializers", + "-Wno-return-type" + ], "libraries": ["-lrealm"], "xcode_settings": { "CLANG_CXX_LANGUAGE_STANDARD": "c++14", "CLANG_CXX_LIBRARY": "libc++", + "GCC_ENABLE_CPP_EXCEPTIONS": "YES", + "GCC_ENABLE_CPP_RTTI": "YES", "MACOSX_DEPLOYMENT_TARGET": "10.8", - "OTHER_CPLUSPLUSFLAGS": ["-fexceptions", "-frtti"], "OTHER_LDFLAGS": ["-framework", "Foundation"] }, + "conditions": [ + [ + "OS=='linux'", { + "sources": [ + "../object-store/src/impl/android/external_commit_helper.cpp", + ] + } + ], + ["OS=='mac'", { + "sources": [ + "../object-store/src/impl/apple/external_commit_helper.cpp" + ] + }] + ], "configurations": { "Debug": { "defines": ["DEBUG=1"] diff --git a/src/object-store/src/impl/external_commit_helper.hpp b/src/object-store/src/impl/external_commit_helper.hpp index 0abbd56c..920f978f 100644 --- a/src/object-store/src/impl/external_commit_helper.hpp +++ b/src/object-store/src/impl/external_commit_helper.hpp @@ -23,7 +23,7 @@ #if REALM_PLATFORM_APPLE #include "impl/apple/external_commit_helper.hpp" -#elif REALM_ANDROID +#elif REALM_ANDROID || REALM_PLATFORM_NODE #include "impl/android/external_commit_helper.hpp" #else #include "impl/generic/external_commit_helper.hpp" diff --git a/src/object-store/src/impl/transact_log_handler.cpp b/src/object-store/src/impl/transact_log_handler.cpp index 85d44bd6..0a130ea1 100644 --- a/src/object-store/src/impl/transact_log_handler.cpp +++ b/src/object-store/src/impl/transact_log_handler.cpp @@ -444,7 +444,7 @@ public: LinkViewObserver(_impl::TransactionChangeInfo& info) : m_info(info) { } - void mark_dirty(size_t row, __unused size_t col) + void mark_dirty(size_t row, size_t) { if (auto change = get_change()) change->modify(row);