-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #65 from joaovitorsilvestre/arrumando_a_casa
Arrumando a casa
- Loading branch information
Showing
54 changed files
with
923 additions
and
420 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
**/_compiled/ | ||
/bin/ | ||
/Makefile | ||
**/erl_crash.dump | ||
**/erl_crash.dump | ||
bootstraped |
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 |
---|---|---|
|
@@ -5,4 +5,5 @@ | |
src/_compiled | ||
/example/ | ||
**/erl_crash.dump | ||
fy_doc/_env | ||
libs/fy_doc/_env | ||
bootstraped |
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
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,52 @@ | ||
#!/bin/bash | ||
set -eo pipefail # stop if any error | ||
|
||
compile () { | ||
# We use the _COMP sufix to avoid conflict with external variables | ||
# (variabls of the shell that is running this script) | ||
SRC_DIR_COMP=$1 | ||
DESTINE_PATH_COMP=$2 | ||
PATH_FYTHON_TO_USE_AS_BOOTSTRAPER_COMP=$3 | ||
ELIXIR_BEAMS_PATH_COMP=$4 | ||
COMPILE_IN_PARALEL=true | ||
|
||
ALL_FILES_PATH_COMP=$(find $SRC_DIR_COMP -name '*.fy') | ||
|
||
echo "Destine folder: $DESTINE_PATH_COMP" | ||
rm -rf $DESTINE_PATH_COMP | ||
mkdir $DESTINE_PATH_COMP | ||
|
||
cd $ELIXIR_BEAMS_PATH_COMP && cp -r . "$DESTINE_PATH_COMP" && cd / | ||
|
||
EXIT_CODES_PATH=/tmp/bootstra_exit_codes | ||
rm -rf $EXIT_CODES_PATH | ||
mkdir $EXIT_CODES_PATH | ||
|
||
for FILE_PATH in $ALL_FILES_PATH_COMP; do | ||
ERL_COMMAND_CALL="application:start(compiler), application:start(elixir), 'Elixir.Code':compiler_options(#{ignore_module_conflict => true}), 'Fython.Core.Code':compile_project_file(<<"'"'$SRC_DIR_COMP'"'">>, <<"'"'${FILE_PATH}'"'">>, "'"'$DESTINE_PATH_COMP'"'"), init:stop()."; | ||
FILE_PATH_SCAPED=$(echo $FILE_PATH | sed 's/\//SEPARATOR/g') | ||
|
||
if [ "$COMPILE_IN_PARALEL" = true ] ; then | ||
erl -pa $PATH_FYTHON_TO_USE_AS_BOOTSTRAPER_COMP -noshell -eval "$ERL_COMMAND_CALL" || echo $? > $EXIT_CODES_PATH/$FILE_PATH_SCAPED & | ||
else | ||
erl -pa $PATH_FYTHON_TO_USE_AS_BOOTSTRAPER_COMP -noshell -eval "$ERL_COMMAND_CALL" || echo $? > $EXIT_CODES_PATH/$FILE_PATH_SCAPED | ||
fi | ||
done | ||
wait | ||
|
||
# when running in parallel we need this to ensure that all comands returned 0 code | ||
# otherwise this script would return 0 code even when some erl command failed | ||
for RESULT in `ls $EXIT_CODES_PATH`; do | ||
ORIGINAL_PATH=$(echo $RESULT | sed 's/SEPARATOR/\//g') | ||
RESULT=$(cat $EXIT_CODES_PATH/$RESULT) | ||
if [[ $RESULT -ne "0" ]]; then | ||
echo "Bootstrap Failed --------------------" | ||
echo "Failed to compile files: $ORIGINAL_PATH" | ||
echo "-------------------------------------" | ||
exit 1 | ||
fi | ||
done | ||
echo "Bootstraped with success" | ||
} | ||
|
||
$* |
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,45 @@ | ||
def run(path): | ||
# TODO it should compile the tests module | ||
|
||
test_functions_per_module = Fytest.Discover.find_test_functions(path) | ||
Elixir.IO.puts('Colleted tests:') | ||
Elixir.IO.inspect(test_functions_per_module) | ||
run_tests(test_functions_per_module) | ||
|
||
def run_tests(test_functions_per_module): | ||
results_per_module = test_functions_per_module | ||
|> Elixir.Enum.map(lambda (module, functions): | ||
results = functions | ||
|> Elixir.Enum.map( | ||
lambda (test_name, arity): | ||
execute_test(module, test_name, arity) | ||
) | ||
(module, results) | ||
) | ||
|
||
results_per_module | ||
|> Elixir.Enum.map(lambda (module, results): | ||
show_results(results) | ||
) | ||
|
||
def show_results(results): | ||
passed = results | ||
|> Elixir.Enum.filter(lambda (status, _, _, _, _): status == :passed) | ||
|> Elixir.Enum.map(lambda (_, module, test_name, _, _): | ||
Elixir.IO.puts(Elixir.Enum.join(["PASSED: ", module, test_name])) | ||
) | ||
|
||
Elixir.IO.puts('=========================') | ||
|
||
failed = results | ||
|> Elixir.Enum.filter(lambda (status, _, _, _, _): status == :failed) | ||
|> Elixir.Enum.map(lambda (_, module, test_name, error, stacktrace): | ||
Elixir.IO.puts(Elixir.Enum.join(["FAILED: ", module, test_name])) | ||
) | ||
|
||
def execute_test(module, test_name, _arity): | ||
try: | ||
Elixir.Kernel.apply(module, test_name, []) | ||
(:passed, module, test_name, None, None) | ||
except error: | ||
(:failed, module, test_name, error, __STACKTRACE__) |
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,40 @@ | ||
def get_module_name_of_path(path): | ||
path | ||
|> Elixir.String.replace_suffix('/', '') | ||
|> Elixir.String.split('/') | ||
|> Elixir.Enum.at(-1) | ||
|> Elixir.Macro.camelize() | ||
|
||
def find_test_functions(test_module): | ||
modules = get_modules(test_module) | ||
|
||
modules | ||
|> Elixir.Enum.map( | ||
lambda module: | ||
functions = module |> get_tests_of_module() | ||
(module, functions) | ||
) | ||
|
||
def get_tests_of_module(module): | ||
module | ||
|> get_functions_of_module() | ||
|> Elixir.Enum.filter(lambda (func_name, _arity): | ||
func_name | ||
|> Elixir.Atom.to_string() | ||
|> Elixir.String.starts_with?("test_") | ||
) | ||
|
||
def get_functions_of_module(module): | ||
# get_functions_of_module(:"Fython.Shell") | ||
# TODO go to core | ||
Elixir.Kernel.apply(module, :__info__, [:functions]) | ||
|
||
def get_modules(path): | ||
[path, "**/*.fy"] | ||
|> Elixir.Enum.join('/') | ||
|> Elixir.Path.wildcard() | ||
|> Elixir.Enum.map(lambda file_full_path: | ||
module_name = Core.Code.get_module_name(path, file_full_path) | ||
(:module, module) = Elixir.Code.ensure_loaded(Elixir.String.to_atom(module_name)) | ||
module | ||
) |
Oops, something went wrong.