Skip to content

Commit

Permalink
tests: avoid generating lua code when running tests
Browse files Browse the repository at this point in the history
  • Loading branch information
StunxFS committed Jul 4, 2024
1 parent 7754f37 commit 95aa263
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
3 changes: 2 additions & 1 deletion bsc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ def compile(self):
self.sema.check_files(self.source_files)
if report.errors > 0:
exit(1)
self.codegen.gen_files(self.source_files)
if not self.prefs.is_check:
self.codegen.gen_files(self.source_files)

def import_modules(self):
for sf in self.source_files:
Expand Down
8 changes: 7 additions & 1 deletion bsc/prefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def __init__(self):
self.is_library = False

self.pkg_name = ""
self.is_check = False
self.is_verbose = False

def parse_args(self):
Expand All @@ -27,14 +28,19 @@ def parse_args(self):
'--lib', action = 'store_true',
help = 'specifies whether the input is a library or not'
)
parser.add_argument(
'--check', action = 'store_true',
help = 'scans, parses, and checks the files without compiling.'
)
parser.add_argument(
'-v', '--verbose', action = 'store_true',
help = 'Enable verbosity in the compiler while compiling'
help = 'enable verbosity in the compiler while compiling'
)
args = parser.parse_args()

self.is_library = args.lib
self.pkg_name = args.pkg_name or ""
self.is_check = args.check
self.is_verbose = args.verbose

# check input file
Expand Down
4 changes: 3 additions & 1 deletion bsc/sym.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ def has_access_to(self, other):
case AccessModifier.internal:
return self.get_pkg() == other.get_pkg()
case AccessModifier.private:
return self.get_mod() == other.get_mod()
if self_mod := self.get_mod():
if other_mod := other.get_mod():
return self_mod == other_mod
return False

def kind_of(self):
Expand Down
2 changes: 1 addition & 1 deletion tests/check_invalid_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
for i, bs_file in enumerate(bs_files):
out_file = bs_file[:-3] + ".out"
print(f" [{i+1}/{len(bs_files)}] {utils.bold(bs_file)}", end = "")
res = utils.execute(f"python3", "bsc", bs_file)
res = utils.execute(f"python3", "bsc", "--check", bs_file)
if res.exit_code == 0:
print(utils.bold(utils.red(" -> FAILED")))
fail += 1
Expand Down

0 comments on commit 95aa263

Please sign in to comment.