mirror of
https://github.com/kanaka/mal.git
synced 2024-09-11 13:55:55 +03:00
Fix second-order self-hosting.
The `_map?` function was introduced when transitioning the macro property being stored in metadata to uinsg a regular map with a special key. The `_map?` function causes issues in a few places but the biggest issue is that it breaks the `_macro?` function for the second order self-hosted mal instance. The `_macro?` function contains a `(map? x)` call that returns false resulting in the `_macro?` call returning false. I'll push something later that fixes this and also that activates second order self-hosted tests so we can catch this sort of issue in the future.
This commit is contained in:
parent
38daa6955b
commit
ff4e5f1600
@ -53,7 +53,10 @@ matrix:
|
||||
- {env: IMPL=logo NO_SELF_HOST=1, services: [docker]} # step4 timeout
|
||||
- {env: IMPL=lua, services: [docker]}
|
||||
- {env: IMPL=make NO_SELF_HOST=1, services: [docker]} # step4 timeout
|
||||
- {env: IMPL=mal BUILD_IMPL=js NO_SELF_HOST=1, services: [docker]}
|
||||
- {env: IMPL=mal MAL_IMPL=js BUILD_IMPL=js NO_SELF_HOST=1, services: [docker]}
|
||||
- {env: IMPL=mal MAL_IMPL=js-mal BUILD_IMPL=js NO_SELF_HOST=1, services: [docker]}
|
||||
- {env: IMPL=mal MAL_IMPL=nim BUILD_IMPL=nim NO_SELF_HOST=1, services: [docker]}
|
||||
- {env: IMPL=mal MAL_IMPL=nim-mal BUILD_IMPL=nim NO_SELF_HOST=1, services: [docker]}
|
||||
- {env: IMPL=matlab NO_SELF_HOST_PERF=1, services: [docker]} # Octave, perf timeout
|
||||
- {env: IMPL=miniMAL NO_SELF_HOST_PERF=1, services: [docker]} # perf timeout
|
||||
- {env: IMPL=nasm NO_SELF_HOST_PERF=1, services: [docker]} # perf OOM
|
||||
|
@ -44,7 +44,7 @@ if [ -z "${NO_DOCKER}" ]; then
|
||||
img_impl=$(echo "${MAL_IMPL:-${IMPL}}" | tr '[:upper:]' '[:lower:]')
|
||||
# We could just use make DOCKERIZE=1 instead but that does add
|
||||
# non-trivial startup overhead for each step.
|
||||
MAKE="docker run -it -u $(id -u) -v `pwd`:/mal kanaka/mal-test-${img_impl} ${MAKE}"
|
||||
MAKE="docker run -it -u $(id -u) -v `pwd`:/mal kanaka/mal-test-${img_impl%%-mal} ${MAKE}"
|
||||
fi
|
||||
|
||||
case "${ACTION}" in
|
||||
|
8
Makefile
8
Makefile
@ -291,7 +291,7 @@ STEP_TEST_FILES = $(strip $(wildcard \
|
||||
lc = $(subst A,a,$(subst B,b,$(subst C,c,$(subst D,d,$(subst E,e,$(subst F,f,$(subst G,g,$(subst H,h,$(subst I,i,$(subst J,j,$(subst K,k,$(subst L,l,$(subst M,m,$(subst N,n,$(subst O,o,$(subst P,p,$(subst Q,q,$(subst R,r,$(subst S,s,$(subst T,t,$(subst U,u,$(subst V,v,$(subst W,w,$(subst X,x,$(subst Y,y,$(subst Z,z,$1))))))))))))))))))))))))))
|
||||
impl_to_image = kanaka/mal-test-$(call lc,$(1))
|
||||
|
||||
actual_impl = $(if $(filter mal,$(1)),$(MAL_IMPL),$(1))
|
||||
actual_impl = $(if $(filter mal,$(1)),$(patsubst %-mal,%,$(MAL_IMPL)),$(1))
|
||||
|
||||
# Takes impl
|
||||
# Returns nothing if DOCKERIZE is not set, otherwise returns the
|
||||
@ -400,7 +400,7 @@ $(foreach i,$(DO_IMPLS),$(foreach s,$(STEPS),build^$(i)^$(s))): $$(call $$(word
|
||||
$(ALL_TESTS): $$(call $$(word 2,$$(subst ^, ,$$(@)))_STEP_TO_PROG,$$(word 3,$$(subst ^, ,$$(@))))
|
||||
@$(foreach impl,$(word 2,$(subst ^, ,$(@))),\
|
||||
$(foreach step,$(word 3,$(subst ^, ,$(@))),\
|
||||
cd $(if $(filter mal,$(impl)),$(MAL_IMPL),$(impl)) && \
|
||||
cd $(call actual_impl,$(impl)) && \
|
||||
$(foreach test,$(call STEP_TEST_FILES,$(impl),$(step)),\
|
||||
echo '----------------------------------------------' && \
|
||||
echo 'Testing $@; step file: $+, test file: $(test)' && \
|
||||
@ -455,7 +455,7 @@ perf: $(IMPL_PERF)
|
||||
$(IMPL_PERF):
|
||||
@echo "----------------------------------------------"; \
|
||||
$(foreach impl,$(word 2,$(subst ^, ,$(@))),\
|
||||
cd $(if $(filter mal,$(impl)),$(MAL_IMPL),$(impl)); \
|
||||
cd $(call actual_impl,$(impl)); \
|
||||
echo "Performance test for $(impl):"; \
|
||||
echo 'Running: $(call get_run_prefix,$(impl),stepA) ../$(impl)/run ../tests/perf1.mal'; \
|
||||
$(call get_run_prefix,$(impl),stepA) ../$(impl)/run ../tests/perf1.mal; \
|
||||
@ -472,7 +472,7 @@ $(IMPL_PERF):
|
||||
$(ALL_REPL): $$(call $$(word 2,$$(subst ^, ,$$(@)))_STEP_TO_PROG,$$(word 3,$$(subst ^, ,$$(@))))
|
||||
@$(foreach impl,$(word 2,$(subst ^, ,$(@))),\
|
||||
$(foreach step,$(word 3,$(subst ^, ,$(@))),\
|
||||
cd $(if $(filter mal,$(impl)),$(MAL_IMPL),$(impl)); \
|
||||
cd $(call actual_impl,$(impl)); \
|
||||
echo 'REPL implementation $(impl), step file: $+'; \
|
||||
echo 'Running: $(call get_run_prefix,$(impl),$(step)) ../$(impl)/run $(RUN_ARGS)'; \
|
||||
$(call get_run_prefix,$(impl),$(step)) ../$(impl)/run $(RUN_ARGS);))
|
||||
|
@ -1,8 +1,3 @@
|
||||
(def! _map? (fn* [x]
|
||||
(if (map? x)
|
||||
(not (contains? x :__MAL_MACRO__))
|
||||
false)))
|
||||
|
||||
(def! _macro? (fn* [x]
|
||||
(if (map? x)
|
||||
(contains? x :__MAL_MACRO__)
|
||||
@ -45,7 +40,7 @@
|
||||
['vector vector]
|
||||
['vector? vector?]
|
||||
['hash-map hash-map]
|
||||
['map? _map?]
|
||||
['map? map?]
|
||||
['assoc assoc]
|
||||
['dissoc dissoc]
|
||||
['get get]
|
||||
|
5
mal/run
5
mal/run
@ -1,4 +1,9 @@
|
||||
#!/bin/bash
|
||||
MAL_FILE=../mal/${STEP:-stepA_mal}.mal
|
||||
export STEP=stepA_mal # force MAL_IMPL to use stepA
|
||||
case ${MAL_IMPL} in
|
||||
*-mal)
|
||||
MAL_IMPL=${MAL_IMPL%%-mal}
|
||||
MAL_FILE="../mal/stepA_mal.mal ${MAL_FILE}" ;;
|
||||
esac
|
||||
exec ./../${MAL_IMPL:-js}/run ${MAL_FILE} "${@}"
|
||||
|
@ -48,10 +48,10 @@
|
||||
|
||||
(vector? ast) (apply vector (map (fn* [exp] (EVAL exp env)) ast))
|
||||
|
||||
(_map? ast) (apply hash-map
|
||||
(apply concat
|
||||
(map (fn* [k] [k (EVAL (get ast k) env)])
|
||||
(keys ast))))
|
||||
(map? ast) (apply hash-map
|
||||
(apply concat
|
||||
(map (fn* [k] [k (EVAL (get ast k) env)])
|
||||
(keys ast))))
|
||||
|
||||
"else" ast)))
|
||||
|
||||
@ -87,7 +87,8 @@
|
||||
(EVAL (QUASIQUOTE (nth ast 1)) env)
|
||||
|
||||
(= 'defmacro! a0)
|
||||
(env-set env (nth ast 1) {:__MAL_MACRO__ (EVAL (nth ast 2) env)})
|
||||
(env-set env (nth ast 1) (hash-map :__MAL_MACRO__
|
||||
(EVAL (nth ast 2) env)))
|
||||
|
||||
(= 'macroexpand a0)
|
||||
(MACROEXPAND (nth ast 1) env)
|
||||
|
@ -48,10 +48,10 @@
|
||||
|
||||
(vector? ast) (apply vector (map (fn* [exp] (EVAL exp env)) ast))
|
||||
|
||||
(_map? ast) (apply hash-map
|
||||
(apply concat
|
||||
(map (fn* [k] [k (EVAL (get ast k) env)])
|
||||
(keys ast))))
|
||||
(map? ast) (apply hash-map
|
||||
(apply concat
|
||||
(map (fn* [k] [k (EVAL (get ast k) env)])
|
||||
(keys ast))))
|
||||
|
||||
"else" ast)))
|
||||
|
||||
@ -87,7 +87,8 @@
|
||||
(EVAL (QUASIQUOTE (nth ast 1)) env)
|
||||
|
||||
(= 'defmacro! a0)
|
||||
(env-set env (nth ast 1) {:__MAL_MACRO__ (EVAL (nth ast 2) env)})
|
||||
(env-set env (nth ast 1) (hash-map :__MAL_MACRO__
|
||||
(EVAL (nth ast 2) env)))
|
||||
|
||||
(= 'macroexpand a0)
|
||||
(MACROEXPAND (nth ast 1) env)
|
||||
|
@ -48,10 +48,10 @@
|
||||
|
||||
(vector? ast) (apply vector (map (fn* [exp] (EVAL exp env)) ast))
|
||||
|
||||
(_map? ast) (apply hash-map
|
||||
(apply concat
|
||||
(map (fn* [k] [k (EVAL (get ast k) env)])
|
||||
(keys ast))))
|
||||
(map? ast) (apply hash-map
|
||||
(apply concat
|
||||
(map (fn* [k] [k (EVAL (get ast k) env)])
|
||||
(keys ast))))
|
||||
|
||||
"else" ast)))
|
||||
|
||||
@ -87,7 +87,8 @@
|
||||
(EVAL (QUASIQUOTE (nth ast 1)) env)
|
||||
|
||||
(= 'defmacro! a0)
|
||||
(env-set env (nth ast 1) {:__MAL_MACRO__ (EVAL (nth ast 2) env)})
|
||||
(env-set env (nth ast 1) (hash-map :__MAL_MACRO__
|
||||
(EVAL (nth ast 2) env)))
|
||||
|
||||
(= 'macroexpand a0)
|
||||
(MACROEXPAND (nth ast 1) env)
|
||||
|
@ -372,9 +372,6 @@
|
||||
(= [] {})
|
||||
;=>false
|
||||
|
||||
(map? cond)
|
||||
;=>false
|
||||
|
||||
(keyword :abc)
|
||||
;=>:abc
|
||||
(keyword? (first (keys {":abc" 123 ":def" 456})))
|
||||
|
Loading…
Reference in New Issue
Block a user