Skip to content

Add livecode submodule and travis config #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tests/_lcs_test_suite.log
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "livecode"]
path = livecode
url = https://github.com/livecode/livecode
106 changes: 106 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
sudo: required
dist: trusty

# Build on both Linux and OSX
os:
- linux
- osx

# Use a Travis image containing an Xcode we support
# This prevents surprise upgrades!
osx_image: xcode7.3

language: c++

compiler:
- clang
- gcc

# Environment variables
env:
global:
- CXX_STD: "c++11"

jdk:
- openjdk8

# Build using clang on mac and gcc on linux
matrix:
exclude:
- os: osx
compiler: gcc
- os: linux
compiler: clang

# Install any required tools
before_install:
- |
if [[ "$TRAVIS_OS_NAME" == "osx" ]] ; then
rvm --default use 2.2.1
gem install xcpretty
fi

- |
if [[ "$TRAVIS_OS_NAME" == "linux" ]] ; then
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
sudo apt-get -qq update
sudo apt-get -qq install g++-4.9
fi

# Set up the source tree by fetching correct prebuilt objects
install:
- if [[ "$TRAVIS_OS_NAME" == "linux" ]] ; then (cd livecode/prebuilt && ./fetch-libraries.sh linux) ; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]] ; then (cd livecode/prebuilt && ./fetch-libraries.sh mac) ; fi

# Build the default target for LiveCode
script: |
case "${TRAVIS_OS_NAME}" in
linux)
BUILD_PLATFORM=linux
CHECK_COMMAND=xvfb-run
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:"${JAVA_HOME}/jre/lib/amd64/server"
export CXX="g++-4.9"
export CC="gcc-4.9"
;;
osx)
BUILD_PLATFORM=mac
CHECK_COMMAND=
export XCODE_TARGET_SDK=macosx10.11
export XCODEBUILD="set -o pipefail && xcodebuild"
export XCODEBUILD_FILTER="| xcpretty"
export JAVA_HOME=$(/usr/libexec/java_home)
;;
esac
export MODE=debug

make -C livecode all-${BUILD_PLATFORM}
if [ $? -ne 0 ] ; then
echo " compile failed"
exit 1
fi
${CHECK_COMMAND} make -C tests lcs-check
if [ $? -ne 0 ] ; then
echo " tests failed - dumping log file"
cat tests/_lcs_test_suite.log
exit 1
fi

addons:
# Packages needed for building LiveCode
apt:
packages:
- gawk
- libx11-dev
- libxext-dev
- libxrender-dev
- libxft-dev
- libxinerama-dev
- libxv-dev
- libxcursor-dev
- libfreetype6-dev
- libgtk2.0-dev
- libpopt-dev
- libesd0-dev
- liblcms2-dev
- xvfb

1 change: 1 addition & 0 deletions livecode
Submodule livecode added at 4b29ad
14 changes: 14 additions & 0 deletions tests/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# This Makefile takes advantage of the fact that the LiveCode engine's
# "tests/Makefile" already does pretty much everything required for
# running a test suite. Rather than duplicating it, it can
# just be included with a few tweaks to its configuration.

# Override the default value of top_srcdir so that it points to the
# top of the engine repository.
top_srcdir = ../livecode

LCS_TESTS_DIR = test-scripts

# Things have now been setup enough that the engine's test Makefile
# can perform the tests without any further configuration.
include $(top_srcdir)/tests/Makefile
94 changes: 94 additions & 0 deletions tests/test-scripts/test.livecodescript
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
script "TestCiphers"

on TestSetup
local tSourceFile
put the filename of me into tSourceFile
set the itemdelimiter to slash
put "src/PuzzleTools.livecodescript" into item -3 to -1 of tSourceFile
start using stack tSourceFile
end TestSetup

private command TestAssertUserThrows pDesc, pHandler, pError
local tError
try
dispatch pHandler to me
catch tError
end try

TestAssert pDesc, tError is pError

if tError is not pError then
TestDiagnostic "Expected error:" && pError
TestDiagnostic "Actual error:" && tError
end if
end TestAssertUserThrows

on LetterToNumberThrow
get toNumber("'")
end LetterToNumberThrow

on TestLetterToNumber
local tIndex
put 0 into tIndex
repeat for each char tChar in "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
add 1 to tIndex
TestAssert "uppercase letter" && tChar && "to number correct", \
toNumber(tChar) is tIndex
end repeat

put 0 into tIndex
repeat for each char tChar in "abcdefghijklmnopqrstuvwxyz"
add 1 to tIndex
TestAssert "lowercase letter" && tChar && "to number correct", \
toNumber(tChar) is tIndex
end repeat

TestAssertUserThrows "non alphabetic input to toNumber function throws", \
"LetterToNumberThrow", "char not alphabetical"
end TestLetterToNumber

on TestLetterFromNumber
local tIndex
put 0 into tIndex
repeat for each char tChar in "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
add 1 to tIndex
TestAssert "uppercase letter" && tChar && "from number correct", \
fromNumber(tIndex) is tChar
end repeat

put 0 into tIndex
repeat for each char tChar in "abcdefghijklmnopqrstuvwxyz"
add 1 to tIndex
TestAssert "lowercase letter" && tChar && "from number correct", \
fromNumber(tIndex) is tChar
end repeat
end TestLetterFromNumber

command _TestCaesarCipher pDesc, pSource, pShift, pExpected
local tResult, tSuccess
put caesarShift(pSource, pShift) into tResult
put tResult is pExpected into tSuccess
TestAssert pDesc, tSuccess

// If the test failed then log the actual output of caesarShift
if not tSuccess then
TestDiagnostic pDesc && "failed"
TestDiagnostic "Expected result:" && pExpected
TestDiagnostic "Actual result:" && tResult
end if
end _TestCaesarCipher

on TestCaesarCipher
_TestCaesarCipher "abjurer <-> nowhere (13)", "abjurer", 13, "nowhere"
_TestCaesarCipher "inkier <-> purply (7)", "inkier", 7, "purply"
_TestCaesarCipher "fusion <-> layout (6)", "fusion", 6, "layout"
_TestCaesarCipher "manful <-> thumbs (7)", "manful", 7, "thumbs"
_TestCaesarCipher "primero <-> sulphur (3)", "primero", 3, "sulphur"
_TestCaesarCipher "steeds <-> tuffet (1)", "steeds", 1, "tuffet"
end TestCaesarCipher

on TestVigenereCipher
TestAssert "LIVECODE encoded using vigenere cipher with key TEST is EMNXVSVX", \
vigenereShift("LIVECODE","TEST") is "EMNXVSVX"
end TestVigenereCipher