Skip to content
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

bash script which tests that amberc command generates the js file #1095

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
43 changes: 43 additions & 0 deletions external/amber-cli/tests/ambercTest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash

# Tests if the `amberc` command generates a js file
# Displays 'ok' in green if test succeeds, else 'not ok' in red.

AMBERC_COMMAND="amberc"
ST_FILE_PATH="fixture/HelloApp.st"
JS_FILE_PATH="fixture/HelloApp.js"
RED="1;31"
GREEN="1;32"

function makeItColorful {
echo -e "\e[$2m$1\e[0m"
}

function cleanJsFile {
rm -rf $JS_FILE_PATH
}

# Asserts that test succeeded and displays the result
# Expected args: result testNumber testName
function assert {
result=$1
testNumber=$2
testName=$3
if [ $result -eq 0 ]
then
makeItColorful "ok $testNumber - $testName" $GREEN
else
makeItColorful "not ok $testNumber - $testName" $RED
fi
}

# Compile Amber file with amberc #
$AMBERC_COMMAND $ST_FILE_PATH > /dev/null 2>&1

# Test JS file generation #
[ -f $JS_FILE_PATH ]
fileExists=$?
assert $fileExists 1 "Test js file generation"

cleanJsFile
exit $fileExists
10 changes: 10 additions & 0 deletions external/amber-cli/tests/fixture/HelloApp.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Smalltalk createPackage: 'HelloApp'!
Object subclass: #Hello
instanceVariableNames: ''
package: 'HelloApp'!

!Hello methodsFor: 'not yet classified'!

begin
Transcript show "Hello"
! !