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")
# 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)
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]")
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}]...')
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}'...")
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
--- /dev/null
+0
\ No newline at end of file
--- /dev/null
+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
--- /dev/null
+-1
\ No newline at end of file
--- /dev/null
+0
\ No newline at end of file
--- /dev/null
+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
--- /dev/null
+-1
\ No newline at end of file
--- /dev/null
+0
\ No newline at end of file
--- /dev/null
+strings.momo:1:1 [STRING] 'This is a string!'
+strings.momo:4:9 [STRING] 'This too is a string!'
+[INFO] OK
--- /dev/null
+-1
\ No newline at end of file
+++ /dev/null
-0
\ No newline at end of file
+++ /dev/null
-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
+++ /dev/null
--1
\ No newline at end of file
+++ /dev/null
-0
\ No newline at end of file
+++ /dev/null
-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
+++ /dev/null
--1
\ No newline at end of file
+++ /dev/null
-0
\ No newline at end of file
+++ /dev/null
-strings.momo:1:1 [STRING] 'This is a string!'
-strings.momo:4:9 [STRING] 'This too is a string!'
-[INFO] OK
+++ /dev/null
--1
\ No newline at end of file