Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Theo Weidmann
committed
Feb 5, 2017
1 parent
927d4d5
commit dd0f8ed
Showing
7 changed files
with
170 additions
and
148 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
cmake_minimum_required(VERSION 3.2.2) | ||
project(Emojicode) | ||
|
||
set(CMAKE_CXX_STANDARD 14) | ||
set(CMAKE_C_STANDARD 11) | ||
|
||
if(heapSize) | ||
add_definitions(-DheapSize=${heapSize}) | ||
endif() | ||
|
||
if(defaultPackagesDirectory) | ||
add_definitions(-DdefaultPackagesDirectory=${defaultPackagesDirectory}) | ||
endif() | ||
|
||
file(GLOB EMOJICODE_SOURCES "EmojicodeReal-TimeEngine/*") | ||
add_executable(emojicode ${EMOJICODE_SOURCES} utf8.c utf8.h) | ||
target_compile_options(emojicode PUBLIC -Ofast -Wall -Wno-unused-result -Wno-missing-braces -pedantic) | ||
target_link_libraries(emojicode dl pthread) | ||
|
||
file(GLOB EMOJICODEC_SOURCES "EmojicodeCompiler/*") | ||
add_executable(emojicodec ${EMOJICODEC_SOURCES} utf8.c utf8.h) | ||
target_compile_options(emojicodec PUBLIC -Ofast -Wall -Wno-unused-result -Wno-missing-braces -pedantic) | ||
|
||
add_custom_target(dist python3 ${PROJECT_SOURCE_DIR}/dist.py ${PROJECT_SOURCE_DIR}) | ||
add_custom_target(tests python3 ${PROJECT_SOURCE_DIR}/tests.py ${PROJECT_SOURCE_DIR} DEPENDS dist) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import platform | ||
import shutil | ||
import os | ||
import sys | ||
|
||
source = sys.argv[1] | ||
version = "0.5.0-dev" | ||
packages = [("files", 0)] | ||
dist_name = "Emojicode-{0}-{1}-{2}".format(version, platform.system(), | ||
platform.machine()) | ||
path = dist_name | ||
|
||
if __name__ == "__main__": | ||
if os.path.exists(path): | ||
shutil.rmtree(path) | ||
os.makedirs(path) | ||
|
||
shutil.copy2(os.path.join(source, "install.sh"), | ||
os.path.join(path, "install.sh")) | ||
os.makedirs(os.path.join(path, "packages", "s")) | ||
shutil.copy2(os.path.join(source, "headers", "s.emojic"), | ||
os.path.join(path, "packages", "s", "header.emojic")) | ||
|
||
for package, version in packages: | ||
dir_path = os.path.join(path, "packages", package) | ||
os.makedirs(dir_path) | ||
shutil.copy2(os.path.join(source, "headers", package + ".emojic"), | ||
os.path.join(path, "packages", package, "header.emojic")) | ||
symlink_name = os.path.join(path, "packages", | ||
"{0}-v{1}".format(package, version)) | ||
os.symlink(package, symlink_name) | ||
# TODO: Copy binaries | ||
|
||
shutil.copy2("emojicode", os.path.join(path, "emojicode")) | ||
shutil.copy2("emojicodec", os.path.join(path, "emojicodec")) | ||
shutil.make_archive(dist_name, "gztar", path) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
from subprocess import * | ||
import glob | ||
import os | ||
import dist | ||
|
||
os.environ["EMOJICODE_PACKAGES_PATH"] = os.path.join(dist.path, "packages") | ||
|
||
compilation_tests = [ | ||
"hello", "intTest", "branch", "namespace", "enum", "unwrap", | ||
"conditionalProduce", "piglatin", "stringConcat", "extension", "class", | ||
"babyBottleInitializer", "valueType", "isNothingness", "downcastClass", | ||
"protocol", "callable", "threads", "variableInitAndScoping" | ||
# gcStressTest chaining | ||
] | ||
library_tests = [ | ||
"stringTest", "primitives", "mathTest", "listTest", "rangeTest", | ||
"dataTest", "dictionaryTest", "systemTest", "jsonTest", "enumerator" | ||
# fileTest | ||
] | ||
reject_tests = glob.glob(os.path.join(dist.source, "tests", "reject,", | ||
"*.emojic")) | ||
|
||
failed_tests = [] | ||
|
||
|
||
def fail_test(name): | ||
global failed_tests | ||
print("🛑 {0} failed".format(name)) | ||
failed_tests.append(name) | ||
|
||
|
||
def test_paths(name, kind): | ||
return (os.path.join(dist.source, "tests", kind, name + ".emojic"), | ||
os.path.join(dist.source, "tests", kind, name + ".emojib")) | ||
|
||
|
||
def library_test(name): | ||
source_path, binary_path = test_paths(name, 's') | ||
|
||
run(["./emojicodec", source_path], check=True) | ||
completed = run(["./emojicode", binary_path], stdout=PIPE) | ||
if completed.returncode != 0: | ||
fail_test(name) | ||
print(completed.stdout.decode('utf-8')) | ||
|
||
|
||
def compilation_test(name): | ||
source_path, binary_path = test_paths(name, 'compilation') | ||
|
||
run(["./emojicodec", source_path], check=True) | ||
completed = run(["./emojicode", binary_path], stdout=PIPE) | ||
exp_path = os.path.join(dist.source, "tests", "compilation", name + ".txt") | ||
if completed.stdout.decode('utf-8') != open(exp_path, "r").read(): | ||
fail_test(name) | ||
|
||
|
||
def reject_test(filename): | ||
completed = run(["./emojicodec", filename], stderr=DEVNULL) | ||
if completed.returncode == 0: | ||
fail_test(filename) | ||
|
||
|
||
for test in compilation_tests: | ||
compilation_test(test) | ||
for test in reject_tests: | ||
reject_test(test) | ||
for test in library_tests: | ||
library_test(test) | ||
|
||
if len(failed_tests) == 0: | ||
print("✅ ✅ All tests passed.") | ||
else: | ||
print("🛑 🛑 {0} tests failed: {1}".format(len(failed_tests), | ||
", ".join(failed_tests))) |