]> www.git.momoyon.org Git - lang.git/commitdiff
[testing] Prefix expected outputs with . (make it hidden)
authorahmedsamyh <ahmedsamyh10@gmail.com>
Mon, 3 Mar 2025 12:45:13 +0000 (17:45 +0500)
committerahmedsamyh <ahmedsamyh10@gmail.com>
Mon, 3 Mar 2025 12:45:13 +0000 (17:45 +0500)
37 files changed:
test.py
tests/.identifiers.build.code.expected [new file with mode: 0644]
tests/.identifiers.build.err.expected [new file with mode: 0644]
tests/.identifiers.build.out.expected [new file with mode: 0644]
tests/.identifiers.code.expected [new file with mode: 0644]
tests/.identifiers.err.expected [new file with mode: 0644]
tests/.identifiers.out.expected [new file with mode: 0644]
tests/.operators.build.code.expected [new file with mode: 0644]
tests/.operators.build.err.expected [new file with mode: 0644]
tests/.operators.build.out.expected [new file with mode: 0644]
tests/.operators.code.expected [new file with mode: 0644]
tests/.operators.err.expected [new file with mode: 0644]
tests/.operators.out.expected [new file with mode: 0644]
tests/.strings.build.code.expected [new file with mode: 0644]
tests/.strings.build.err.expected [new file with mode: 0644]
tests/.strings.build.out.expected [new file with mode: 0644]
tests/.strings.code.expected [new file with mode: 0644]
tests/.strings.err.expected [new file with mode: 0644]
tests/.strings.out.expected [new file with mode: 0644]
tests/identifiers.build.code.expected [deleted file]
tests/identifiers.build.err.expected [deleted file]
tests/identifiers.build.out.expected [deleted file]
tests/identifiers.code.expected [deleted file]
tests/identifiers.err.expected [deleted file]
tests/identifiers.out.expected [deleted file]
tests/operators.build.code.expected [deleted file]
tests/operators.build.err.expected [deleted file]
tests/operators.build.out.expected [deleted file]
tests/operators.code.expected [deleted file]
tests/operators.err.expected [deleted file]
tests/operators.out.expected [deleted file]
tests/strings.build.code.expected [deleted file]
tests/strings.build.err.expected [deleted file]
tests/strings.build.out.expected [deleted file]
tests/strings.code.expected [deleted file]
tests/strings.err.expected [deleted file]
tests/strings.out.expected [deleted file]

diff --git a/test.py b/test.py
index 87642fde72abe6cd1d19bf0563c379a8352fe968..17b5fafbe41bf34ea0a95a1271762aa2fa97086d 100755 (executable)
--- a/test.py
+++ b/test.py
@@ -21,7 +21,7 @@ class Test:
         self.name = name
 
         def read_or_create_expected_file(name: str) -> str:
-            f = f"{self.name}.{name}.expected"
+            f = self.get_expected_filename(name)
             if not os.path.exists(f):
                 with open(f, "w") as file:
                     print(f"[INFO] Created empty {self.name}.{name}.expected")
@@ -50,7 +50,7 @@ class Test:
         # if self.expected_stderr: print(f"{self.name}.err.expected: {self.expected_stderr}")
     def save_expected(self):
         def write_expected(name: str, content: str):
-            f = f"{self.name}.{name}.expected"
+            f = self.get_expected_filename(name)
             with open(f, "w") as file:
                 file.write(content)
 
@@ -62,6 +62,12 @@ class Test:
         write_expected("build.err", self.build_expected_stderr)
         write_expected("build.code", str(self.build_expected_returncode))
 
+    def get_expected_filename(self, name):
+        if name not in [ "out", "err", "code", "build.out", "build.err", "build.code" ]:
+            raise Exception("Please pass a valid name")
+            
+        return f".{self.name}.{name}.expected"
+
 
 def usage(program: str):
     print(f"Usage: {program} <subcmd> [flags]")
@@ -188,6 +194,7 @@ def main():
 
                 print(f"Build {passing_tests_count}/{total_tests_count} tests")
         elif subcmd == "run":
+            assert False, "'run' Subcommand is not fully tested!"
             print(f'----- [RUN] -----')
             for test_name in tests:
                 print(f'+ Running {test_name} [{current_test_id+1}/{total_tests_count}]...')
@@ -219,6 +226,7 @@ def main():
 
             print(f"PASSED {passing_tests_count}/{total_tests_count}")
         elif subcmd == "record":
+            assert False, "'record' Subcommand is not fully tested!"
             print(f'----- [RECORD] -----')
             for test_name in tests:
                 print(f"+ Recording expected behaviour for '{test_name}'...")
@@ -259,7 +267,6 @@ def main():
                 ans = input(prompt_msg)
 
                 if ans.lower() == "y":
-
                     tests[test_name].build_expected_stdout = res.stdout
                     tests[test_name].build_expected_stderr = res.stderr
                     tests[test_name].build_expected_returncode = res.returncode
diff --git a/tests/.identifiers.build.code.expected b/tests/.identifiers.build.code.expected
new file mode 100644 (file)
index 0000000..c227083
--- /dev/null
@@ -0,0 +1 @@
+0
\ No newline at end of file
diff --git a/tests/.identifiers.build.err.expected b/tests/.identifiers.build.err.expected
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/tests/.identifiers.build.out.expected b/tests/.identifiers.build.out.expected
new file mode 100644 (file)
index 0000000..d8a895b
--- /dev/null
@@ -0,0 +1,11 @@
+identifiers.momo:1:0 [IDENT] 'foo'
+identifiers.momo:2:1 [IDENT] 'bar'
+identifiers.momo:2:5 [IDENT] 'baz'
+identifiers.momo:8:0 [IDENT] 'A'
+identifiers.momo:8:2 [IDENT] 'B'
+identifiers.momo:8:4 [IDENT] 'C'
+identifiers.momo:10:0 [IDENT] '_D'
+identifiers.momo:10:3 [IDENT] 'eE'
+identifiers.momo:10:6 [IDENT] '_F'
+identifiers.momo:10:9 [IDENT] '_G'
+[INFO] OK
diff --git a/tests/.identifiers.code.expected b/tests/.identifiers.code.expected
new file mode 100644 (file)
index 0000000..d7d17fc
--- /dev/null
@@ -0,0 +1 @@
+-1
\ No newline at end of file
diff --git a/tests/.identifiers.err.expected b/tests/.identifiers.err.expected
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/tests/.identifiers.out.expected b/tests/.identifiers.out.expected
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/tests/.operators.build.code.expected b/tests/.operators.build.code.expected
new file mode 100644 (file)
index 0000000..c227083
--- /dev/null
@@ -0,0 +1 @@
+0
\ No newline at end of file
diff --git a/tests/.operators.build.err.expected b/tests/.operators.build.err.expected
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/tests/.operators.build.out.expected b/tests/.operators.build.out.expected
new file mode 100644 (file)
index 0000000..37c4a50
--- /dev/null
@@ -0,0 +1,27 @@
+operators.momo:1:7 [MINUS] '-'
+operators.momo:2:0 [MINUS_MINUS] '--'
+operators.momo:3:0 [RETURNER] '->'
+operators.momo:4:0 [PLUS] '+'
+operators.momo:5:0 [PLUS_PLUS] '++'
+operators.momo:6:0 [PLUS_EQUAL] '+='
+operators.momo:7:0 [DIVIDE] '/'
+operators.momo:8:0 [DIVIDE_EQUAL] '/='
+operators.momo:9:0 [MULTIPLY] '*'
+operators.momo:10:0 [POWER] '**'
+operators.momo:11:0 [MULTIPLY_EQUAL] '*='
+operators.momo:12:0 [MODULUS] '%'
+operators.momo:13:0 [MODULUS_EQUAL] '%='
+operators.momo:15:0 [BITWISE_AND] '&'
+operators.momo:16:0 [BITWISE_AND_EQUAL] '&='
+operators.momo:17:0 [BITWISE_XOR] '^'
+operators.momo:18:0 [BITWISE_XOR_EQUAL] '^='
+operators.momo:19:0 [BITWISE_NOT] '~'
+operators.momo:20:0 [BITWISE_OR] '|'
+operators.momo:21:0 [BITWISE_OR_EQUAL] '|='
+operators.momo:23:0 [NOT] '!'
+operators.momo:24:0 [NOT_EQUAL] '!='
+operators.momo:25:0 [LOGICAL_AND] '&&'
+operators.momo:26:0 [LOGICAL_OR] '||'
+operators.momo:28:0 [EQUAL] '='
+operators.momo:29:0 [EQUAL_EQUAL] '=='
+[INFO] OK
diff --git a/tests/.operators.code.expected b/tests/.operators.code.expected
new file mode 100644 (file)
index 0000000..d7d17fc
--- /dev/null
@@ -0,0 +1 @@
+-1
\ No newline at end of file
diff --git a/tests/.operators.err.expected b/tests/.operators.err.expected
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/tests/.operators.out.expected b/tests/.operators.out.expected
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/tests/.strings.build.code.expected b/tests/.strings.build.code.expected
new file mode 100644 (file)
index 0000000..c227083
--- /dev/null
@@ -0,0 +1 @@
+0
\ No newline at end of file
diff --git a/tests/.strings.build.err.expected b/tests/.strings.build.err.expected
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/tests/.strings.build.out.expected b/tests/.strings.build.out.expected
new file mode 100644 (file)
index 0000000..214376d
--- /dev/null
@@ -0,0 +1,3 @@
+strings.momo:1:1 [STRING] 'This is a string!'
+strings.momo:4:9 [STRING] 'This too is a string!'
+[INFO] OK
diff --git a/tests/.strings.code.expected b/tests/.strings.code.expected
new file mode 100644 (file)
index 0000000..d7d17fc
--- /dev/null
@@ -0,0 +1 @@
+-1
\ No newline at end of file
diff --git a/tests/.strings.err.expected b/tests/.strings.err.expected
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/tests/.strings.out.expected b/tests/.strings.out.expected
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/tests/identifiers.build.code.expected b/tests/identifiers.build.code.expected
deleted file mode 100644 (file)
index c227083..0000000
+++ /dev/null
@@ -1 +0,0 @@
-0
\ No newline at end of file
diff --git a/tests/identifiers.build.err.expected b/tests/identifiers.build.err.expected
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/tests/identifiers.build.out.expected b/tests/identifiers.build.out.expected
deleted file mode 100644 (file)
index d8a895b..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-identifiers.momo:1:0 [IDENT] 'foo'
-identifiers.momo:2:1 [IDENT] 'bar'
-identifiers.momo:2:5 [IDENT] 'baz'
-identifiers.momo:8:0 [IDENT] 'A'
-identifiers.momo:8:2 [IDENT] 'B'
-identifiers.momo:8:4 [IDENT] 'C'
-identifiers.momo:10:0 [IDENT] '_D'
-identifiers.momo:10:3 [IDENT] 'eE'
-identifiers.momo:10:6 [IDENT] '_F'
-identifiers.momo:10:9 [IDENT] '_G'
-[INFO] OK
diff --git a/tests/identifiers.code.expected b/tests/identifiers.code.expected
deleted file mode 100644 (file)
index d7d17fc..0000000
+++ /dev/null
@@ -1 +0,0 @@
--1
\ No newline at end of file
diff --git a/tests/identifiers.err.expected b/tests/identifiers.err.expected
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/tests/identifiers.out.expected b/tests/identifiers.out.expected
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/tests/operators.build.code.expected b/tests/operators.build.code.expected
deleted file mode 100644 (file)
index c227083..0000000
+++ /dev/null
@@ -1 +0,0 @@
-0
\ No newline at end of file
diff --git a/tests/operators.build.err.expected b/tests/operators.build.err.expected
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/tests/operators.build.out.expected b/tests/operators.build.out.expected
deleted file mode 100644 (file)
index 37c4a50..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-operators.momo:1:7 [MINUS] '-'
-operators.momo:2:0 [MINUS_MINUS] '--'
-operators.momo:3:0 [RETURNER] '->'
-operators.momo:4:0 [PLUS] '+'
-operators.momo:5:0 [PLUS_PLUS] '++'
-operators.momo:6:0 [PLUS_EQUAL] '+='
-operators.momo:7:0 [DIVIDE] '/'
-operators.momo:8:0 [DIVIDE_EQUAL] '/='
-operators.momo:9:0 [MULTIPLY] '*'
-operators.momo:10:0 [POWER] '**'
-operators.momo:11:0 [MULTIPLY_EQUAL] '*='
-operators.momo:12:0 [MODULUS] '%'
-operators.momo:13:0 [MODULUS_EQUAL] '%='
-operators.momo:15:0 [BITWISE_AND] '&'
-operators.momo:16:0 [BITWISE_AND_EQUAL] '&='
-operators.momo:17:0 [BITWISE_XOR] '^'
-operators.momo:18:0 [BITWISE_XOR_EQUAL] '^='
-operators.momo:19:0 [BITWISE_NOT] '~'
-operators.momo:20:0 [BITWISE_OR] '|'
-operators.momo:21:0 [BITWISE_OR_EQUAL] '|='
-operators.momo:23:0 [NOT] '!'
-operators.momo:24:0 [NOT_EQUAL] '!='
-operators.momo:25:0 [LOGICAL_AND] '&&'
-operators.momo:26:0 [LOGICAL_OR] '||'
-operators.momo:28:0 [EQUAL] '='
-operators.momo:29:0 [EQUAL_EQUAL] '=='
-[INFO] OK
diff --git a/tests/operators.code.expected b/tests/operators.code.expected
deleted file mode 100644 (file)
index d7d17fc..0000000
+++ /dev/null
@@ -1 +0,0 @@
--1
\ No newline at end of file
diff --git a/tests/operators.err.expected b/tests/operators.err.expected
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/tests/operators.out.expected b/tests/operators.out.expected
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/tests/strings.build.code.expected b/tests/strings.build.code.expected
deleted file mode 100644 (file)
index c227083..0000000
+++ /dev/null
@@ -1 +0,0 @@
-0
\ No newline at end of file
diff --git a/tests/strings.build.err.expected b/tests/strings.build.err.expected
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/tests/strings.build.out.expected b/tests/strings.build.out.expected
deleted file mode 100644 (file)
index 214376d..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-strings.momo:1:1 [STRING] 'This is a string!'
-strings.momo:4:9 [STRING] 'This too is a string!'
-[INFO] OK
diff --git a/tests/strings.code.expected b/tests/strings.code.expected
deleted file mode 100644 (file)
index d7d17fc..0000000
+++ /dev/null
@@ -1 +0,0 @@
--1
\ No newline at end of file
diff --git a/tests/strings.err.expected b/tests/strings.err.expected
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/tests/strings.out.expected b/tests/strings.out.expected
deleted file mode 100644 (file)
index e69de29..0000000