Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
typon
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Tom Niget
typon
Commits
ba744ffa
Commit
ba744ffa
authored
Aug 15, 2023
by
Tom Niget
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update test_runner.py
parent
1ba51c0b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
8 deletions
+12
-8
trans/test_runner.py
trans/test_runner.py
+12
-8
No files found.
trans/test_runner.py
View file @
ba744ffa
# coding: utf-8
import
argparse
import
logging
#logging.basicConfig(level=logging.DEBUG)
from
os
import
system
,
environ
from
pathlib
import
Path
...
...
@@ -17,12 +19,15 @@ load_dotenv()
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
"-c"
,
"--compile"
,
action
=
"store_true"
)
parser
.
add_argument
(
"-g"
,
"--generate"
,
action
=
"store_true"
)
parser
.
add_argument
(
"-o"
,
"--only"
,
nargs
=
"+"
)
args
=
parser
.
parse_args
()
def
run_tests
():
def
run_tests
():
for
path
in
Path
(
'tests'
).
glob
(
'*.py'
):
if
args
.
only
and
path
.
stem
not
in
args
.
only
:
continue
print
(
path
.
name
)
if
path
.
name
.
startswith
(
'_'
):
print
(
"Skipping"
)
...
...
@@ -30,6 +35,7 @@ def run_tests():
with
open
(
path
,
"r"
,
encoding
=
"utf-8"
)
as
f
:
code
=
f
.
read
()
execute
=
"# norun"
not
in
code
compile
=
"# nocompile"
not
in
code
res
=
format_code
(
transpile
(
code
,
path
.
name
,
path
))
#print(res)
name_cpp
=
path
.
with_suffix
(
'.cpp'
)
...
...
@@ -38,15 +44,13 @@ def run_tests():
print
(
".cpp generated"
)
if
args
.
compile
:
continue
if
not
execute
:
print
(
"Not executing"
,
path
.
name
)
continue
execute_str
=
"true"
if
(
execute
and
not
args
.
generate
)
else
"false"
name_bin
=
path
.
with_suffix
(
''
).
as_posix
()
commands
=
[
f'bash -c "
PYTHONPATH=stdlib python3 ./
{
path
.
as_posix
()
}
"'
,
f'bash -c "
export PYTHONPATH=stdlib; if
{
execute_str
}
; then python3 ./
{
path
.
as_posix
()
}
; fi
"'
,
]
if
alt
:
=
environ
.
get
(
"ALT_RUNNER"
):
commands
.
append
(
alt
.
format
(
name_bin
=
name_bin
,
name_cpp_posix
=
name_cpp
.
as_posix
()))
if
compile
and
(
alt
:
=
environ
.
get
(
"ALT_RUNNER"
)
):
commands
.
append
(
alt
.
format
(
name_bin
=
name_bin
,
name_cpp_posix
=
name_cpp
.
as_posix
()
,
run_file
=
execute_str
))
else
:
print
(
"no ALT_RUNNER"
)
for
cmd
in
commands
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment