-
Notifications
You must be signed in to change notification settings - Fork 217
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add test compile for example scripts
- Loading branch information
1 parent
cfe0bf5
commit 2415af6
Showing
3 changed files
with
60 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
""" | ||
This file is part of PIConGPU. | ||
Copyright 2021-2023 PIConGPU contributors | ||
Authors: Brian Edward Marre | ||
License: GPLv3+ | ||
""" | ||
|
||
from picongpu import pypicongpu | ||
|
||
import shutil | ||
import importlib.util | ||
import sys | ||
|
||
import unittest | ||
|
||
|
||
class TestExamples(unittest.TestCase): | ||
def __load_example_script(self, path): | ||
"""load and execute example PICMI script from given path""" | ||
spec = importlib.util.spec_from_file_location("example", path) | ||
example_script = importlib.util.module_from_spec(spec) | ||
|
||
sys.modules["example"] = example_script | ||
spec.loader.exec_module(example_script) | ||
|
||
sim = example.sim # noqa | ||
output_path = example.OUTPUT_DIRECTORY_PATH # noqa | ||
|
||
return sim, output_path | ||
|
||
def __build_simulation(sim): | ||
"""build the given instance of simulation""" | ||
runner = pypicongpu.Runner(sim) | ||
runner.generate(printDirToConsole=True) | ||
runner.build() | ||
|
||
def test_LWFA_example(self): | ||
sim, output_path = self.__load_example_script( | ||
"$PICSRC/share/picongpu/pypicongpu/examples/laser_wakefield/main.py" | ||
) | ||
|
||
self.__try_to_build(sim) | ||
|
||
# remove generated output | ||
shutil.rmtree(output_path) | ||
|
||
def test_warm_plasma_example(self): | ||
sim, output_path = self.__load_example_script("$PICSRC/share/picongpu/pypicongpu/examples/warm_plasma/main.py") | ||
|
||
self.__try_to_build(sim) | ||
|
||
# remove generated output | ||
shutil.rmtree(output_path) |