public inbox for ~johnnyrichard/olang-devel@lists.sr.ht
 help / color / mirror / code / Atom feed
* [PATCH olang v2 0/3] improve test's makes and compiler binary
@ 2024-09-22 15:15 Johnny Richard
  2024-09-22 15:15 ` [PATCH olang v2 1/3] olc: rename 'olang' binary to 'olc' Johnny Richard
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Johnny Richard @ 2024-09-22 15:15 UTC (permalink / raw)
  To: ~johnnyrichard/olang-devel; +Cc: Johnny Richard

This is an attempt of improving the development experience by changing
the folder strucutre for tests and making a better usage of make
execution to enable parallelization support.

This patchset also changes the compiler binary from olang to olc.

- V2:
  - rename olang binary to olc
  - fix missing docs instructions for the new build
  - replace 'execute' folder by 'olc' under tests

Johnny Richard (3):
  olc: rename 'olang' binary to 'olc'
  tests: build: enhance compiler tests
  tests: build: add parallelization support for unit tests

 .gitignore                                    |  2 +-
 Makefile                                      | 31 ++++++--------
 docs/info/contribution-guide.texi             |  5 +--
 docs/info/installation.texi                   |  4 +-
 docs/man/man1/{olang.1 => olc.1}              | 10 ++---
 tests/integration/Makefile                    |  9 -----
 .../tests => olc}/0001_main_exit.ol           | 24 +++++------
 .../0002_binary_operator_addition.ol          |  0
 .../0003_binary_operator_multiplication.ol    |  0
 .../0004_binary_operator_division.ol          |  0
 .../0005_binary_operator_reminder.ol          |  0
 .../0006_binary_operator_subtraction.ol       |  0
 .../tests => olc}/0007_binary_operator_eq.ol  |  0
 .../tests => olc}/0008_binary_operator_lt.ol  |  0
 .../tests => olc}/0009_binary_operator_gt.ol  |  0
 .../tests => olc}/0010_binary_operator_neq.ol |  0
 .../tests => olc}/0011_binary_operator_leq.ol |  0
 .../tests => olc}/0012_binary_operator_geq.ol |  0
 .../0013_binary_operator_lshift.ol            |  0
 .../0014_binary_operator_rshift.ol            |  0
 .../tests => olc}/0015_binary_operator_xor.ol |  2 +-
 .../tests => olc}/0016_binary_operator_and.ol |  0
 .../tests => olc}/0017_binary_operator_or.ol  |  0
 .../0018_binary_operator_logical_and.ol       |  0
 .../0019_binary_operator_logical_or.ol        |  0
 .../tests => olc}/0020_if_statement.ol        |  2 +-
 .../tests => olc}/0021_if_statement_failed.ol |  0
 .../0022_if_statement_literal.ol              |  0
 .../tests => olc}/0023_else_statement.ol      |  2 +-
 .../tests => olc}/0024_var_definition.ol      |  2 +-
 .../0025_var_definition_nested.ol             |  0
 .../tests => olc}/0026_primitive_unsigneds.ol |  0
 tests/olc/0026_primitive_unsigneds.ol.orig    | 27 +++++++++++++
 tests/olc/Makefile                            | 15 +++++++
 tests/{integration/test.sh => olc/run.sh}     |  2 +-
 tests/unit/Makefile                           | 40 +++++++++----------
 36 files changed, 100 insertions(+), 77 deletions(-)
 rename docs/man/man1/{olang.1 => olc.1} (87%)
 delete mode 100644 tests/integration/Makefile
 rename tests/{integration/tests => olc}/0001_main_exit.ol (66%)
 rename tests/{integration/tests => olc}/0002_binary_operator_addition.ol (100%)
 rename tests/{integration/tests => olc}/0003_binary_operator_multiplication.ol (100%)
 rename tests/{integration/tests => olc}/0004_binary_operator_division.ol (100%)
 rename tests/{integration/tests => olc}/0005_binary_operator_reminder.ol (100%)
 rename tests/{integration/tests => olc}/0006_binary_operator_subtraction.ol (100%)
 rename tests/{integration/tests => olc}/0007_binary_operator_eq.ol (100%)
 rename tests/{integration/tests => olc}/0008_binary_operator_lt.ol (100%)
 rename tests/{integration/tests => olc}/0009_binary_operator_gt.ol (100%)
 rename tests/{integration/tests => olc}/0010_binary_operator_neq.ol (100%)
 rename tests/{integration/tests => olc}/0011_binary_operator_leq.ol (100%)
 rename tests/{integration/tests => olc}/0012_binary_operator_geq.ol (100%)
 rename tests/{integration/tests => olc}/0013_binary_operator_lshift.ol (100%)
 rename tests/{integration/tests => olc}/0014_binary_operator_rshift.ol (100%)
 rename tests/{integration/tests => olc}/0015_binary_operator_xor.ol (96%)
 rename tests/{integration/tests => olc}/0016_binary_operator_and.ol (100%)
 rename tests/{integration/tests => olc}/0017_binary_operator_or.ol (100%)
 rename tests/{integration/tests => olc}/0018_binary_operator_logical_and.ol (100%)
 rename tests/{integration/tests => olc}/0019_binary_operator_logical_or.ol (100%)
 rename tests/{integration/tests => olc}/0020_if_statement.ol (96%)
 rename tests/{integration/tests => olc}/0021_if_statement_failed.ol (100%)
 rename tests/{integration/tests => olc}/0022_if_statement_literal.ol (100%)
 rename tests/{integration/tests => olc}/0023_else_statement.ol (96%)
 rename tests/{integration/tests => olc}/0024_var_definition.ol (96%)
 rename tests/{integration/tests => olc}/0025_var_definition_nested.ol (100%)
 rename tests/{integration/tests => olc}/0026_primitive_unsigneds.ol (100%)
 create mode 100644 tests/olc/0026_primitive_unsigneds.ol.orig
 create mode 100644 tests/olc/Makefile
 rename tests/{integration/test.sh => olc/run.sh} (99%)


base-commit: e35d8835bf464a0f4de8b731fc248a7188fccef1
-- 
2.46.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH olang v2 1/3] olc: rename 'olang' binary to 'olc'
  2024-09-22 15:15 [PATCH olang v2 0/3] improve test's makes and compiler binary Johnny Richard
@ 2024-09-22 15:15 ` Johnny Richard
  2024-09-22 15:15 ` [PATCH olang v2 2/3] tests: build: enhance compiler tests Johnny Richard
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Johnny Richard @ 2024-09-22 15:15 UTC (permalink / raw)
  To: ~johnnyrichard/olang-devel; +Cc: Johnny Richard

In the future we might need more binaries to our toolchain, by now we
want to delimit the scope of this binary to only handle compilation
related jobs.

Fun fact, the name 'olc' can be interpreted as an abbreviation for ".ol
compiler".

Signed-off-by: Johnny Richard <johnny@johnnyrichard.com>
---
 .gitignore                        |  2 +-
 Makefile                          | 14 +++++++-------
 docs/info/contribution-guide.texi |  5 ++---
 docs/info/installation.texi       |  4 ++--
 docs/man/man1/{olang.1 => olc.1}  | 10 +++++-----
 tests/integration/test.sh         |  2 +-
 6 files changed, 18 insertions(+), 19 deletions(-)
 rename docs/man/man1/{olang.1 => olc.1} (87%)

diff --git a/.gitignore b/.gitignore
index 0fe0790..f18560c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,4 @@
-olang
+/olc
 build
 *.o
 *.info
diff --git a/Makefile b/Makefile
index 12b09a4..0603526 100644
--- a/Makefile
+++ b/Makefile
@@ -6,7 +6,7 @@ CFLAGS := ${CFLAGS}
 CFLAGS += -Werror -Wall -Wextra -Wmissing-declarations
 CFLAGS += -pedantic -std=c11 -ggdb
 
-TARGET := olang
+TARGET := olc
 
 PREFIX ?= /usr/local
 
@@ -41,9 +41,9 @@ install-bin: $(TARGET)
 install-man: install-man1
 
 .PHONY: install-man1
-install-man1: docs/man/man1/olang.1
-	install -Dm 644 docs/man/man1/olang.1 ${DESTDIR}${MAN1DIR}/olang.1
-	gzip -f ${DESTDIR}${MAN1DIR}/olang.1
+install-man1: docs/man/man1/olc.1
+	install -Dm 644 docs/man/man1/olc.1 ${DESTDIR}${MAN1DIR}/olc.1
+	gzip -f ${DESTDIR}${MAN1DIR}/olc.1
 
 .PHONY: install-info
 install-info: olang.info
@@ -56,15 +56,15 @@ install-info: olang.info
 uninstall: uninstall-bin uninstall-man uninstall-info
 
 .PHONY: uninstall-bin
-uninstall-bin: ${DESTDIR}${BINDIR}/olang
-	@rm -f ${DESTDIR}${BINDIR}/olang
+uninstall-bin: ${DESTDIR}${BINDIR}/$(TARGET)
+	@rm -f ${DESTDIR}${BINDIR}/$(TARGET)
 
 .PHONY: uninstall-man
 uninstall-man: uninstall-man1
 
 .PHONY: uninstall-man1
 uninstall-man1:
-	@rm -f ${DESTDIR}${MAN1DIR}/olang.1.gz
+	@rm -f ${DESTDIR}${MAN1DIR}/olc.1.gz
 
 .PHONY: uninstall-info
 uninstall-info:
diff --git a/docs/info/contribution-guide.texi b/docs/info/contribution-guide.texi
index 856d0f6..3d12048 100644
--- a/docs/info/contribution-guide.texi
+++ b/docs/info/contribution-guide.texi
@@ -22,7 +22,7 @@ merely three dependencies: @code{make}, @code{gcc} (version 11 or higher), and
 $ make
 @end example
 
-If everything went well with the compilation, you should find a @code{olang}
+If everything went well with the compilation, you should find a @code{olc}
 binary on the project root folder.
 
 As an optional step, you can install @code{texinfo}, @code{pandoc} and
@@ -32,7 +32,7 @@ read @ref{Writing Documentation}.
 @subsection Testing
 
 There are two layers of tests @strong{integration} and @strong{unit}. The
-integration test is going to execute the @code{olang} compiler and check if the
+integration test is going to execute the @code{olc} compiler and check if the
 generated binary acts as expected. Unit tests will test C functions.
 
 To run all tests you can execute:
@@ -53,7 +53,6 @@ the format section below for guidance on its application.
 @subsection Code Formatting
 
 Checking for format issues:
-
 @example
 $ make format
 @end example
diff --git a/docs/info/installation.texi b/docs/info/installation.texi
index d61b0e9..6ee4a4d 100644
--- a/docs/info/installation.texi
+++ b/docs/info/installation.texi
@@ -4,8 +4,8 @@
 This installation assumes you are running an unix like operation system and
 requires @code{make}, @code{makeinfo} and a @strong{c compiler} installed.
 
-The following commands will compile the the code and install @code{olang}
-binary, @code{man} pages and @code{info} docs into your system.
+The following commands will compile the the code and install @code{olc} binary
+(olang compiler), @code{man} pages and @code{info} docs into your system.
 
 @verbatim
 $ make
diff --git a/docs/man/man1/olang.1 b/docs/man/man1/olc.1
similarity index 87%
rename from docs/man/man1/olang.1
rename to docs/man/man1/olc.1
index fa6544f..5b35f05 100644
--- a/docs/man/man1/olang.1
+++ b/docs/man/man1/olc.1
@@ -1,21 +1,21 @@
-.\" Man page for olang
+.\" Man page for olc
 .\" Contact ~johnnyrichard/olang-devel@lists.sr.ht to report issues
 
-.TH man 1 "Feb 2024" "0.0" "olang man page"
+.TH man 1 "Feb 2024" "0.0" "olc man page"
 
 .SH NAME
 
-olang \- O programming language compiler
+olc \- olang compiler
 
 .SH SYNOPSIS
 
-olang source_file
+olc source_file
 
 [ --dump-tokens ] [ --dump-ast ] [ [ -o output_file [ --save-temps ] [ --arch arch ]  [ --sysroot dir] ]
 
 .SH DESCRIPTION
 
-.B olang
+.B olc
 is the official O programming language compiler, it is also a tool that contains
 utilities to help the language development.
 
diff --git a/tests/integration/test.sh b/tests/integration/test.sh
index 69cbeda..529f0f5 100755
--- a/tests/integration/test.sh
+++ b/tests/integration/test.sh
@@ -16,7 +16,7 @@
 
 # Ignores variables been modified in a subshell
 # shellcheck disable=SC2030,SC2031
-OLANG_PATH="../../olang"
+OLANG_PATH="../../olc"
 TEST_FILE="$1"
 
 TEST_TMP_FILES="$TEST_FILE.test"
-- 
2.46.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH olang v2 2/3] tests: build: enhance compiler tests
  2024-09-22 15:15 [PATCH olang v2 0/3] improve test's makes and compiler binary Johnny Richard
  2024-09-22 15:15 ` [PATCH olang v2 1/3] olc: rename 'olang' binary to 'olc' Johnny Richard
@ 2024-09-22 15:15 ` Johnny Richard
  2024-09-22 15:15 ` [PATCH olang v2 3/3] tests: build: add parallelization support for unit tests Johnny Richard
  2024-09-23  9:09 ` [PATCH olang v2 0/3] improve test's makes and compiler binary Carlos Maniero
  3 siblings, 0 replies; 6+ messages in thread
From: Johnny Richard @ 2024-09-22 15:15 UTC (permalink / raw)
  To: ~johnnyrichard/olang-devel; +Cc: Johnny Richard

There was two problem with the current state of our integration tests:

1) The folder structure is very annoying and long to navigate, the last
   tests folder mess with the shell autocomplete because it has almost
   the same name as the tests.sh script.

2) When we run the make all for integration tests, we are not using the
   make how it was intended to be used.  We have inline shell script
   that loop over all tests and we cannot run tests in parallel.

This change will enable the parallelization and reduce the folder
structure so we can have a better development experience.

Signed-off-by: Johnny Richard <johnny@johnnyrichard.com>
---
 Makefile                                      | 10 +++----
 tests/integration/Makefile                    |  9 -------
 .../tests => olc}/0001_main_exit.ol           | 24 ++++++++---------
 .../0002_binary_operator_addition.ol          |  0
 .../0003_binary_operator_multiplication.ol    |  0
 .../0004_binary_operator_division.ol          |  0
 .../0005_binary_operator_reminder.ol          |  0
 .../0006_binary_operator_subtraction.ol       |  0
 .../tests => olc}/0007_binary_operator_eq.ol  |  0
 .../tests => olc}/0008_binary_operator_lt.ol  |  0
 .../tests => olc}/0009_binary_operator_gt.ol  |  0
 .../tests => olc}/0010_binary_operator_neq.ol |  0
 .../tests => olc}/0011_binary_operator_leq.ol |  0
 .../tests => olc}/0012_binary_operator_geq.ol |  0
 .../0013_binary_operator_lshift.ol            |  0
 .../0014_binary_operator_rshift.ol            |  0
 .../tests => olc}/0015_binary_operator_xor.ol |  2 +-
 .../tests => olc}/0016_binary_operator_and.ol |  0
 .../tests => olc}/0017_binary_operator_or.ol  |  0
 .../0018_binary_operator_logical_and.ol       |  0
 .../0019_binary_operator_logical_or.ol        |  0
 .../tests => olc}/0020_if_statement.ol        |  2 +-
 .../tests => olc}/0021_if_statement_failed.ol |  0
 .../0022_if_statement_literal.ol              |  0
 .../tests => olc}/0023_else_statement.ol      |  2 +-
 .../tests => olc}/0024_var_definition.ol      |  2 +-
 .../0025_var_definition_nested.ol             |  0
 .../tests => olc}/0026_primitive_unsigneds.ol |  0
 tests/olc/0026_primitive_unsigneds.ol.orig    | 27 +++++++++++++++++++
 tests/olc/Makefile                            | 15 +++++++++++
 tests/{integration/test.sh => olc/run.sh}     |  0
 31 files changed, 62 insertions(+), 31 deletions(-)
 delete mode 100644 tests/integration/Makefile
 rename tests/{integration/tests => olc}/0001_main_exit.ol (66%)
 rename tests/{integration/tests => olc}/0002_binary_operator_addition.ol (100%)
 rename tests/{integration/tests => olc}/0003_binary_operator_multiplication.ol (100%)
 rename tests/{integration/tests => olc}/0004_binary_operator_division.ol (100%)
 rename tests/{integration/tests => olc}/0005_binary_operator_reminder.ol (100%)
 rename tests/{integration/tests => olc}/0006_binary_operator_subtraction.ol (100%)
 rename tests/{integration/tests => olc}/0007_binary_operator_eq.ol (100%)
 rename tests/{integration/tests => olc}/0008_binary_operator_lt.ol (100%)
 rename tests/{integration/tests => olc}/0009_binary_operator_gt.ol (100%)
 rename tests/{integration/tests => olc}/0010_binary_operator_neq.ol (100%)
 rename tests/{integration/tests => olc}/0011_binary_operator_leq.ol (100%)
 rename tests/{integration/tests => olc}/0012_binary_operator_geq.ol (100%)
 rename tests/{integration/tests => olc}/0013_binary_operator_lshift.ol (100%)
 rename tests/{integration/tests => olc}/0014_binary_operator_rshift.ol (100%)
 rename tests/{integration/tests => olc}/0015_binary_operator_xor.ol (96%)
 rename tests/{integration/tests => olc}/0016_binary_operator_and.ol (100%)
 rename tests/{integration/tests => olc}/0017_binary_operator_or.ol (100%)
 rename tests/{integration/tests => olc}/0018_binary_operator_logical_and.ol (100%)
 rename tests/{integration/tests => olc}/0019_binary_operator_logical_or.ol (100%)
 rename tests/{integration/tests => olc}/0020_if_statement.ol (96%)
 rename tests/{integration/tests => olc}/0021_if_statement_failed.ol (100%)
 rename tests/{integration/tests => olc}/0022_if_statement_literal.ol (100%)
 rename tests/{integration/tests => olc}/0023_else_statement.ol (96%)
 rename tests/{integration/tests => olc}/0024_var_definition.ol (96%)
 rename tests/{integration/tests => olc}/0025_var_definition_nested.ol (100%)
 rename tests/{integration/tests => olc}/0026_primitive_unsigneds.ol (100%)
 create mode 100644 tests/olc/0026_primitive_unsigneds.ol.orig
 create mode 100644 tests/olc/Makefile
 rename tests/{integration/test.sh => olc/run.sh} (100%)

diff --git a/Makefile b/Makefile
index 0603526..7dbde3e 100644
--- a/Makefile
+++ b/Makefile
@@ -89,10 +89,9 @@ format-fix: $(SRCS) $(HEADERS)
 	clang-format -i $?
 	$(MAKE) -C tests/unit/ format-fix
 
-.PHONY: integration-test
-integration-test:
-	$(MAKE)
-	$(MAKE) -C tests/integration/
+.PHONY: check-olc
+check-olc: $(TARGET)
+	$(MAKE) -C tests/olc/
 
 .PHONY: unit-test
 unit-test:
@@ -106,9 +105,8 @@ clean:
 	@rm -rf build/ $(TARGET)
 
 .PHONY: check
-check:
+check: check-olc
 	$(MAKE)
-	$(MAKE) -C tests/integration/
 	$(MAKE) -C tests/unit/
 
 .PHONY: docs
diff --git a/tests/integration/Makefile b/tests/integration/Makefile
deleted file mode 100644
index bda51af..0000000
--- a/tests/integration/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
-TESTER_SRC := ./test.sh
-TESTS := $(wildcard ./tests/*.ol)
-
-.PHONY: all
-all:
-	@set -e; \
-	for file in $(TESTS); do \
-                $(TESTER_SRC) "$$file"; \
-        done
diff --git a/tests/integration/tests/0001_main_exit.ol b/tests/olc/0001_main_exit.ol
similarity index 66%
rename from tests/integration/tests/0001_main_exit.ol
rename to tests/olc/0001_main_exit.ol
index 9068434..b8abf45 100644
--- a/tests/integration/tests/0001_main_exit.ol
+++ b/tests/olc/0001_main_exit.ol
@@ -31,16 +31,16 @@ fn main(): u32 {
 # END
 #
 # TEST test_contains_tokens WITH
-# ./tests/0001_main_exit.ol:17:1: <fn>
-# ./tests/0001_main_exit.ol:17:4: <identifier>
-# ./tests/0001_main_exit.ol:17:8: <(>
-# ./tests/0001_main_exit.ol:17:9: <)>
-# ./tests/0001_main_exit.ol:17:10: <:>
-# ./tests/0001_main_exit.ol:17:12: <identifier>
-# ./tests/0001_main_exit.ol:17:16: <{>
-# ./tests/0001_main_exit.ol:17:17: <line_feed>
-# ./tests/0001_main_exit.ol:18:3: <return>
-# ./tests/0001_main_exit.ol:18:10: <number>
-# ./tests/0001_main_exit.ol:18:11: <line_feed>
-# ./tests/0001_main_exit.ol:19:1: <}>
+# ./0001_main_exit.ol:17:1: <fn>
+# ./0001_main_exit.ol:17:4: <identifier>
+# ./0001_main_exit.ol:17:8: <(>
+# ./0001_main_exit.ol:17:9: <)>
+# ./0001_main_exit.ol:17:10: <:>
+# ./0001_main_exit.ol:17:12: <identifier>
+# ./0001_main_exit.ol:17:16: <{>
+# ./0001_main_exit.ol:17:17: <line_feed>
+# ./0001_main_exit.ol:18:3: <return>
+# ./0001_main_exit.ol:18:10: <number>
+# ./0001_main_exit.ol:18:11: <line_feed>
+# ./0001_main_exit.ol:19:1: <}>
 # END
diff --git a/tests/integration/tests/0002_binary_operator_addition.ol b/tests/olc/0002_binary_operator_addition.ol
similarity index 100%
rename from tests/integration/tests/0002_binary_operator_addition.ol
rename to tests/olc/0002_binary_operator_addition.ol
diff --git a/tests/integration/tests/0003_binary_operator_multiplication.ol b/tests/olc/0003_binary_operator_multiplication.ol
similarity index 100%
rename from tests/integration/tests/0003_binary_operator_multiplication.ol
rename to tests/olc/0003_binary_operator_multiplication.ol
diff --git a/tests/integration/tests/0004_binary_operator_division.ol b/tests/olc/0004_binary_operator_division.ol
similarity index 100%
rename from tests/integration/tests/0004_binary_operator_division.ol
rename to tests/olc/0004_binary_operator_division.ol
diff --git a/tests/integration/tests/0005_binary_operator_reminder.ol b/tests/olc/0005_binary_operator_reminder.ol
similarity index 100%
rename from tests/integration/tests/0005_binary_operator_reminder.ol
rename to tests/olc/0005_binary_operator_reminder.ol
diff --git a/tests/integration/tests/0006_binary_operator_subtraction.ol b/tests/olc/0006_binary_operator_subtraction.ol
similarity index 100%
rename from tests/integration/tests/0006_binary_operator_subtraction.ol
rename to tests/olc/0006_binary_operator_subtraction.ol
diff --git a/tests/integration/tests/0007_binary_operator_eq.ol b/tests/olc/0007_binary_operator_eq.ol
similarity index 100%
rename from tests/integration/tests/0007_binary_operator_eq.ol
rename to tests/olc/0007_binary_operator_eq.ol
diff --git a/tests/integration/tests/0008_binary_operator_lt.ol b/tests/olc/0008_binary_operator_lt.ol
similarity index 100%
rename from tests/integration/tests/0008_binary_operator_lt.ol
rename to tests/olc/0008_binary_operator_lt.ol
diff --git a/tests/integration/tests/0009_binary_operator_gt.ol b/tests/olc/0009_binary_operator_gt.ol
similarity index 100%
rename from tests/integration/tests/0009_binary_operator_gt.ol
rename to tests/olc/0009_binary_operator_gt.ol
diff --git a/tests/integration/tests/0010_binary_operator_neq.ol b/tests/olc/0010_binary_operator_neq.ol
similarity index 100%
rename from tests/integration/tests/0010_binary_operator_neq.ol
rename to tests/olc/0010_binary_operator_neq.ol
diff --git a/tests/integration/tests/0011_binary_operator_leq.ol b/tests/olc/0011_binary_operator_leq.ol
similarity index 100%
rename from tests/integration/tests/0011_binary_operator_leq.ol
rename to tests/olc/0011_binary_operator_leq.ol
diff --git a/tests/integration/tests/0012_binary_operator_geq.ol b/tests/olc/0012_binary_operator_geq.ol
similarity index 100%
rename from tests/integration/tests/0012_binary_operator_geq.ol
rename to tests/olc/0012_binary_operator_geq.ol
diff --git a/tests/integration/tests/0013_binary_operator_lshift.ol b/tests/olc/0013_binary_operator_lshift.ol
similarity index 100%
rename from tests/integration/tests/0013_binary_operator_lshift.ol
rename to tests/olc/0013_binary_operator_lshift.ol
diff --git a/tests/integration/tests/0014_binary_operator_rshift.ol b/tests/olc/0014_binary_operator_rshift.ol
similarity index 100%
rename from tests/integration/tests/0014_binary_operator_rshift.ol
rename to tests/olc/0014_binary_operator_rshift.ol
diff --git a/tests/integration/tests/0015_binary_operator_xor.ol b/tests/olc/0015_binary_operator_xor.ol
similarity index 96%
rename from tests/integration/tests/0015_binary_operator_xor.ol
rename to tests/olc/0015_binary_operator_xor.ol
index c5c0568..07b6b4a 100644
--- a/tests/integration/tests/0015_binary_operator_xor.ol
+++ b/tests/olc/0015_binary_operator_xor.ol
@@ -13,7 +13,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
 
-# spec: Binary operator ^ 
+# spec: Binary operator ^
 fn main(): u32 {
   return 10 ^ 11
 }
diff --git a/tests/integration/tests/0016_binary_operator_and.ol b/tests/olc/0016_binary_operator_and.ol
similarity index 100%
rename from tests/integration/tests/0016_binary_operator_and.ol
rename to tests/olc/0016_binary_operator_and.ol
diff --git a/tests/integration/tests/0017_binary_operator_or.ol b/tests/olc/0017_binary_operator_or.ol
similarity index 100%
rename from tests/integration/tests/0017_binary_operator_or.ol
rename to tests/olc/0017_binary_operator_or.ol
diff --git a/tests/integration/tests/0018_binary_operator_logical_and.ol b/tests/olc/0018_binary_operator_logical_and.ol
similarity index 100%
rename from tests/integration/tests/0018_binary_operator_logical_and.ol
rename to tests/olc/0018_binary_operator_logical_and.ol
diff --git a/tests/integration/tests/0019_binary_operator_logical_or.ol b/tests/olc/0019_binary_operator_logical_or.ol
similarity index 100%
rename from tests/integration/tests/0019_binary_operator_logical_or.ol
rename to tests/olc/0019_binary_operator_logical_or.ol
diff --git a/tests/integration/tests/0020_if_statement.ol b/tests/olc/0020_if_statement.ol
similarity index 96%
rename from tests/integration/tests/0020_if_statement.ol
rename to tests/olc/0020_if_statement.ol
index 460a05e..9756bb1 100644
--- a/tests/integration/tests/0020_if_statement.ol
+++ b/tests/olc/0020_if_statement.ol
@@ -24,7 +24,7 @@ fn main(): u32 {
 # TEST test_run_binary(exit_code=0)
 #
 # TEST test_contains_tokens WITH
-# ./tests/0020_if_statement.ol:17:3: <if>
+# ./0020_if_statement.ol:17:3: <if>
 # END
 
 # TEST test_ast WITH
diff --git a/tests/integration/tests/0021_if_statement_failed.ol b/tests/olc/0021_if_statement_failed.ol
similarity index 100%
rename from tests/integration/tests/0021_if_statement_failed.ol
rename to tests/olc/0021_if_statement_failed.ol
diff --git a/tests/integration/tests/0022_if_statement_literal.ol b/tests/olc/0022_if_statement_literal.ol
similarity index 100%
rename from tests/integration/tests/0022_if_statement_literal.ol
rename to tests/olc/0022_if_statement_literal.ol
diff --git a/tests/integration/tests/0023_else_statement.ol b/tests/olc/0023_else_statement.ol
similarity index 96%
rename from tests/integration/tests/0023_else_statement.ol
rename to tests/olc/0023_else_statement.ol
index f3ddc64..389e0d4 100644
--- a/tests/integration/tests/0023_else_statement.ol
+++ b/tests/olc/0023_else_statement.ol
@@ -26,7 +26,7 @@ fn main(): u32 {
 # TEST test_run_binary(exit_code=0)
 
 # TEST test_contains_tokens WITH
-# ./tests/0023_else_statement.ol:19:5: <else>
+# ./0023_else_statement.ol:19:5: <else>
 # END
 
 # TEST test_ast WITH
diff --git a/tests/integration/tests/0024_var_definition.ol b/tests/olc/0024_var_definition.ol
similarity index 96%
rename from tests/integration/tests/0024_var_definition.ol
rename to tests/olc/0024_var_definition.ol
index ebbcda4..65deffc 100644
--- a/tests/integration/tests/0024_var_definition.ol
+++ b/tests/olc/0024_var_definition.ol
@@ -23,7 +23,7 @@ fn main(): u32 {
 # TEST test_run_binary(exit_code=0)
 
 # TEST test_contains_tokens WITH
-# ./tests/0024_var_definition.ol:17:3: <var>
+# ./0024_var_definition.ol:17:3: <var>
 # END
 
 # TEST test_ast WITH
diff --git a/tests/integration/tests/0025_var_definition_nested.ol b/tests/olc/0025_var_definition_nested.ol
similarity index 100%
rename from tests/integration/tests/0025_var_definition_nested.ol
rename to tests/olc/0025_var_definition_nested.ol
diff --git a/tests/integration/tests/0026_primitive_unsigneds.ol b/tests/olc/0026_primitive_unsigneds.ol
similarity index 100%
rename from tests/integration/tests/0026_primitive_unsigneds.ol
rename to tests/olc/0026_primitive_unsigneds.ol
diff --git a/tests/olc/0026_primitive_unsigneds.ol.orig b/tests/olc/0026_primitive_unsigneds.ol.orig
new file mode 100644
index 0000000..25f0f7e
--- /dev/null
+++ b/tests/olc/0026_primitive_unsigneds.ol.orig
@@ -0,0 +1,27 @@
+# Copyright (C) 2024 olang mantainers
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <https://www.gnu.org/licenses/>.
+
+fn main(): u64 {
+  var a: u8 = 255
+  var b: u16 = 65535
+  var c: u32 = 4294967295
+  var d: u64 = 4294967296
+
+  return a + b + c + d - a - b - c - d
+}
+
+# TEST test_compile(exit_code=0)
+
+# TEST test_run_binary(exit_code=0)
diff --git a/tests/olc/Makefile b/tests/olc/Makefile
new file mode 100644
index 0000000..c736a78
--- /dev/null
+++ b/tests/olc/Makefile
@@ -0,0 +1,15 @@
+.POSIX:
+
+RUNNER := ./run.sh
+SRCS := $(wildcard *.ol)
+TESTS := $(patsubst %.ol, %.run, $(SRCS))
+
+.SUFFIXES:
+.SUFFIXES: .ol .run
+
+.PHONY: all
+all: $(TESTS)
+
+.ol.run:
+	@$(RUNNER) ./$<
+
diff --git a/tests/integration/test.sh b/tests/olc/run.sh
similarity index 100%
rename from tests/integration/test.sh
rename to tests/olc/run.sh
-- 
2.46.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH olang v2 3/3] tests: build: add parallelization support for unit tests
  2024-09-22 15:15 [PATCH olang v2 0/3] improve test's makes and compiler binary Johnny Richard
  2024-09-22 15:15 ` [PATCH olang v2 1/3] olc: rename 'olang' binary to 'olc' Johnny Richard
  2024-09-22 15:15 ` [PATCH olang v2 2/3] tests: build: enhance compiler tests Johnny Richard
@ 2024-09-22 15:15 ` Johnny Richard
  2024-09-23  9:09 ` [PATCH olang v2 0/3] improve test's makes and compiler binary Carlos Maniero
  3 siblings, 0 replies; 6+ messages in thread
From: Johnny Richard @ 2024-09-22 15:15 UTC (permalink / raw)
  To: ~johnnyrichard/olang-devel; +Cc: Johnny Richard

Removes inline shell script and enable test execution by target on make.

Now we should be able to execute tests with more jobs (make -j<n-of-jobs>)

Signed-off-by: Johnny Richard <johnny@johnnyrichard.com>
---
 Makefile            |  9 +++------
 tests/unit/Makefile | 40 ++++++++++++++++++----------------------
 2 files changed, 21 insertions(+), 28 deletions(-)

diff --git a/Makefile b/Makefile
index 7dbde3e..3a799ae 100644
--- a/Makefile
+++ b/Makefile
@@ -93,9 +93,8 @@ format-fix: $(SRCS) $(HEADERS)
 check-olc: $(TARGET)
 	$(MAKE) -C tests/olc/
 
-.PHONY: unit-test
-unit-test:
-	$(MAKE)
+.PHONY: check-unit
+check-unit: $(TARGET)
 	$(MAKE) -C tests/unit/
 
 .PHONY: clean
@@ -105,9 +104,7 @@ clean:
 	@rm -rf build/ $(TARGET)
 
 .PHONY: check
-check: check-olc
-	$(MAKE)
-	$(MAKE) -C tests/unit/
+check: check-unit check-olc
 
 .PHONY: docs
 docs:
diff --git a/tests/unit/Makefile b/tests/unit/Makefile
index 783225c..686938f 100644
--- a/tests/unit/Makefile
+++ b/tests/unit/Makefile
@@ -1,33 +1,29 @@
-SRCS         := $(wildcard *_test.c)
-OBJS         := $(patsubst %_test.c, %_test.o, $(SRCS))
-SUBJECT_OBJS := $(filter-out ../../build/main.o, $(wildcard ../../build/*.o))
-CFLAGS       := -I../../src -I../shared
-TESTS        := $(patsubst %_test.c, %_test, $(SRCS))
-EXEC_TESTS   := $(patsubst %_test, ./%_test, $(TESTS))
-MUNIT_SRC    := ../shared/munit.c
-MUNIT        := ./munit.o
+SRCS := $(wildcard *.c)
+DEP_OBJS := $(filter-out ../../build/main.o, $(wildcard ../../build/*.o))
+CFLAGS := -I../../src -I../shared
+TESTS := $(patsubst %.c, %.bin, $(SRCS))
+RUN_TESTS := $(patsubst %.bin, %.run, $(TESTS))
+MUNIT_SRC := ../shared/munit.c
+MUNIT := ./munit.o
 
-.PHONY: all
-all: $(MUNIT) $(TESTS)
-	@for file in $(EXEC_TESTS); do \
-                ./"$$file"; \
-        done
+.PHONY: all clean format format-fix
+all: $(RUN_TESTS)
+
+%.bin: %.c $(MUNIT)
+	@$(CC) $(CFLAGS) $(MUNIT) $(DEP_OBJS) $< -o $@
+
+%.run: %.bin
+	@./$<
 
-.PHONY: clean
 clean:
-	$(RM) *.o *_test
-	$(RM) -rfv lib
+	@$(RM) *.o *.bin
+	@$(RM) -rfv lib
 
-.PHONY: format
 format: $(SRCS)
 	clang-format --dry-run --Werror $?
 
-.PHONY: format-fix
 format-fix: $(SRCS)
 	clang-format -i $?
 
-%_test: $(MUNIT) $(SUBJECT_OBJS) %_test.c
-	$(CC) $? $(CFLAGS) -o $@
-
 $(MUNIT):
-	$(CC) -c $(MUNIT_SRC) $(CFLAGS) -o $(MUNIT)
+	@$(CC) -c $(MUNIT_SRC) $(CFLAGS) -o $(MUNIT)
-- 
2.46.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH olang v2 0/3] improve test's makes and compiler binary
  2024-09-22 15:15 [PATCH olang v2 0/3] improve test's makes and compiler binary Johnny Richard
                   ` (2 preceding siblings ...)
  2024-09-22 15:15 ` [PATCH olang v2 3/3] tests: build: add parallelization support for unit tests Johnny Richard
@ 2024-09-23  9:09 ` Carlos Maniero
  2024-09-23 10:57   ` Johnny Richard
  3 siblings, 1 reply; 6+ messages in thread
From: Carlos Maniero @ 2024-09-23  9:09 UTC (permalink / raw)
  To: Johnny Richard, ~johnnyrichard/olang-devel

Great work!

Applied.

To git.sr.ht:~johnnyrichard/olang
   e35d883..06d186e  main -> main

PS: since I don't have permission to trigger the pipeline, could you
please trigger it manually? This patchset updates the manual.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH olang v2 0/3] improve test's makes and compiler binary
  2024-09-23  9:09 ` [PATCH olang v2 0/3] improve test's makes and compiler binary Carlos Maniero
@ 2024-09-23 10:57   ` Johnny Richard
  0 siblings, 0 replies; 6+ messages in thread
From: Johnny Richard @ 2024-09-23 10:57 UTC (permalink / raw)
  To: Carlos Maniero; +Cc: ~johnnyrichard/olang-devel

On Mon, Sep 23, 2024 at 09:09:43AM GMT, Carlos Maniero wrote:
> Great work!
> 
> Applied.
> 
> To git.sr.ht:~johnnyrichard/olang
>    e35d883..06d186e  main -> main
> 
> PS: since I don't have permission to trigger the pipeline, could you
> please trigger it manually? This patchset updates the manual.

Done! Thanks for reviewing it!

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-09-23 10:57 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-22 15:15 [PATCH olang v2 0/3] improve test's makes and compiler binary Johnny Richard
2024-09-22 15:15 ` [PATCH olang v2 1/3] olc: rename 'olang' binary to 'olc' Johnny Richard
2024-09-22 15:15 ` [PATCH olang v2 2/3] tests: build: enhance compiler tests Johnny Richard
2024-09-22 15:15 ` [PATCH olang v2 3/3] tests: build: add parallelization support for unit tests Johnny Richard
2024-09-23  9:09 ` [PATCH olang v2 0/3] improve test's makes and compiler binary Carlos Maniero
2024-09-23 10:57   ` Johnny Richard

Code repositories for project(s) associated with this public inbox

	https://git.johnnyrichard.com/olang.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox