Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions mkconcore.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ def _resolve_concore_path():

if not os.path.isdir(sourcedir):
logging.error(f"{sourcedir} does not exist")
quit()
sys.exit(1)

if len(sys.argv) == 4:
# Use only the output directory name in generated prefixes.
Expand All @@ -269,7 +269,7 @@ def _resolve_concore_path():
concoretype = sys.argv[4]
if not (concoretype in ["posix","windows","docker","macos","ubuntu"]):
logging.error(" type must be posix (macos or ubuntu), windows, or docker")
quit()
sys.exit(1)
ubuntu = False #6/24/21
if concoretype == "ubuntu":
concoretype = "posix"
Expand All @@ -280,7 +280,7 @@ def _resolve_concore_path():
if os.path.exists(outdir):
logging.error(f"{outdir} already exists")
logging.error(f"if intended, Remove/Rename {outdir} first")
quit()
sys.exit(1)

os.makedirs(outdir)
os.chdir(outdir)
Expand Down Expand Up @@ -366,7 +366,7 @@ def cleanup_script_files():
duplicates = {label for label in label_values if label_values.count(label) > 1}
if duplicates:
logging.error(f"Duplicate node labels found: {sorted(duplicates)}")
quit()
sys.exit(1)

for edge in edges_text:
try:
Expand Down Expand Up @@ -623,7 +623,7 @@ def cleanup_script_files():
fsource = open(CONCOREPATH+"/concore.py")
except (FileNotFoundError, IOError):
print(CONCOREPATH+" is not correct path to concore (missing python files)")
quit()
sys.exit(1)
with open(outdir+"/src/concore.py","w") as fcopy:
fcopy.write(fsource.read())
fsource.close()
Expand All @@ -633,14 +633,14 @@ def cleanup_script_files():
fcopy.write(fbase.read())
except (FileNotFoundError, IOError):
print(CONCOREPATH+" is not correct path to concore (missing concore_base.py)")
quit()
sys.exit(1)

if 'jl' in required_langs and concoretype=="docker":
try:
fsource = open(CONCOREPATH+"/concoredocker.jl")
except (FileNotFoundError, IOError):
print(CONCOREPATH+" is not correct path to concore (missing concoredocker.jl)")
quit()
sys.exit(1)
with open(outdir+"/src/concore.jl","w") as fcopy:
fcopy.write(fsource.read())
fsource.close()
Expand All @@ -653,7 +653,7 @@ def cleanup_script_files():
fsource = open(CONCOREPATH+"/concore.hpp")
except (FileNotFoundError, IOError):
print(CONCOREPATH+" is not correct path to concore (missing C++ files)")
quit()
sys.exit(1)
with open(outdir+"/src/concore.hpp","w") as fcopy:
fcopy.write(fsource.read())
fsource.close()
Expand All @@ -666,7 +666,7 @@ def cleanup_script_files():
fsource = open(CONCOREPATH+"/concore.v")
except (FileNotFoundError, IOError):
print(CONCOREPATH+" is not correct path to concore (missing Verilog files)")
quit()
sys.exit(1)
with open(outdir+"/src/concore.v","w") as fcopy:
fcopy.write(fsource.read())
fsource.close()
Expand All @@ -678,7 +678,7 @@ def cleanup_script_files():
fcore = open(CONCOREPATH+"/ConcoreJavaRuntimeCore.java")
except (FileNotFoundError, IOError):
print(CONCOREPATH+" is not correct path to concore (missing Java files)")
quit()
sys.exit(1)
with open(outdir+"/src/"+java_runtime,"w") as fcopy:
fcopy.write(fsource.read())
fsource.close()
Expand Down Expand Up @@ -729,7 +729,7 @@ def cleanup_script_files():
os.chmod(outdir+"/src/mkcompile",stat.S_IRWXU)
except Exception as e:
print(CONCOREPATH+" is not correct path to concore (missing MATLAB files):", e)
quit()
sys.exit(1)

# --- Generate iport and oport mappings ---
logging.info("Generating iport/oport mappings...")
Expand Down Expand Up @@ -828,7 +828,7 @@ def cleanup_script_files():
source_content = fsource.read()
except:
logging.error(f"{CONCOREPATH} is not correct path to concore")
quit()
sys.exit(1)
dockerfile_parent = os.path.dirname(dockerfile_path)
if dockerfile_parent:
os.makedirs(dockerfile_parent, exist_ok=True)
Expand Down Expand Up @@ -1100,7 +1100,7 @@ def cleanup_script_files():
if len(sourcecode)!=0:
if sourcecode.find(".")==-1:
logging.error("cannot pull container "+sourcecode+" with control core type "+concoretype) #3/28/21
quit()
sys.exit(1)
dockername,langext = sourcecode.rsplit(".", 1)
fbuild.write('mkdir '+containername+"\n")
source_subdir = os.path.dirname(sourcecode).replace("\\", "/")
Expand Down Expand Up @@ -1219,7 +1219,7 @@ def cleanup_script_files():
dockername,langext = sourcecode.rsplit(".", 1)
if not (langext in ["py","m","sh","cpp","v","java"]): # 6/22/21
logging.error(f"Extension .{langext} is unsupported")
quit()
sys.exit(1)
if concoretype=="windows":
# manual double quoting for Windows + Input validation above prevents breakout
q_container = f'"{containername}"'
Expand Down
27 changes: 27 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,33 @@ def test_build_command_existing_output(self):
)
self.assertIn("already exists", result.output.lower())

def test_build_command_fails_on_unsupported_extension(self):
with self.runner.isolated_filesystem(temp_dir=self.temp_dir):
result = self.runner.invoke(cli, ["init", "test-project"])
self.assertEqual(result.exit_code, 0)

Path("test-project/src/script.py").rename("test-project/src/script.rb")
workflow_path = Path("test-project/workflow.graphml")
content = workflow_path.read_text()
workflow_path.write_text(content.replace("N1:script.py", "N1:script.rb"))

result = self.runner.invoke(
cli,
[
"build",
"test-project/workflow.graphml",
"--source",
"test-project/src",
"--output",
"out",
"--type",
"posix",
],
)
self.assertNotEqual(result.exit_code, 0)
self.assertIn("Extension .rb is unsupported", result.output)
self.assertFalse(Path("out/STUDY.json").exists())

def test_inspect_command_basic(self):
with self.runner.isolated_filesystem(temp_dir=self.temp_dir):
result = self.runner.invoke(cli, ["init", "test-project"])
Expand Down
Loading