| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /*************************************** | ||
| 2 | Auteur : Thibaut Oprinsen | ||
| 3 | Mail : thibaut.oprinsen@lapp.in2p3.fr | ||
| 4 | Licence : CeCILL-C | ||
| 5 | ****************************************/ | ||
| 6 | |||
| 7 | #include "NanobindTraitTestSetup.h" | ||
| 8 | |||
| 9 | ///Constructor of NanobindTraitTestSetup | ||
| 10 | 1 | NanobindTraitTestSetup::NanobindTraitTestSetup() | |
| 11 | 1 | : PAbstractNanobindTraitBackend() | |
| 12 | 1 | {} | |
| 13 | |||
| 14 | ///Destructor of NanobindTraitTestSetup | ||
| 15 | 2 | NanobindTraitTestSetup::~NanobindTraitTestSetup(){} | |
| 16 | |||
| 17 | ///Registration of static method | ||
| 18 | 2 | void NanobindTraitTestSetup::headerTestInclude(std::ofstream & fs, const GeneratorMode & mode, const PString & baseFileName) const{ | |
| 19 |
3/3✓ Branch 0 (2→3) taken 2 times.
✓ Branch 2 (3→4) taken 2 times.
✓ Branch 4 (4→5) taken 2 times.
|
2 | PString fileModule = baseFileName.toLower() + "_module"; |
| 20 |
2/2✓ Branch 0 (7→8) taken 2 times.
✓ Branch 2 (8→9) taken 2 times.
|
2 | fs << "#!/usr/bin/env python3" << std::endl; |
| 21 |
5/5✓ Branch 0 (9→10) taken 2 times.
✓ Branch 2 (10→11) taken 2 times.
✓ Branch 4 (11→12) taken 2 times.
✓ Branch 6 (12→13) taken 2 times.
✓ Branch 8 (13→14) taken 2 times.
|
2 | fs << "\"\"\"Test script for " << fileModule << " nanobind wrapper\"\"\"" << std::endl << std::endl; |
| 22 |
2/2✓ Branch 0 (14→15) taken 2 times.
✓ Branch 2 (15→16) taken 2 times.
|
2 | fs << "import sys" << std::endl; |
| 23 |
3/3✓ Branch 0 (16→17) taken 2 times.
✓ Branch 2 (17→18) taken 2 times.
✓ Branch 4 (18→19) taken 2 times.
|
2 | fs << "import os" << std::endl << std::endl; |
| 24 | |||
| 25 | // Essayer d'abord l'import direct (environnement pixi), puis avec build_path | ||
| 26 |
2/2✓ Branch 0 (19→20) taken 2 times.
✓ Branch 2 (20→21) taken 2 times.
|
2 | fs << "try:" << std::endl; |
| 27 |
3/3✓ Branch 0 (21→22) taken 2 times.
✓ Branch 2 (22→23) taken 2 times.
✓ Branch 4 (23→24) taken 2 times.
|
2 | fs << "\timport " << fileModule << std::endl; |
| 28 |
4/4✓ Branch 0 (24→25) taken 2 times.
✓ Branch 2 (25→26) taken 2 times.
✓ Branch 4 (26→27) taken 2 times.
✓ Branch 6 (27→28) taken 2 times.
|
2 | fs << "\tprint(\"✓ " << fileModule << " imported successfully from environment!\")" << std::endl; |
| 29 |
2/2✓ Branch 0 (28→29) taken 2 times.
✓ Branch 2 (29→30) taken 2 times.
|
2 | fs << "except ImportError:" << std::endl; |
| 30 |
2/2✓ Branch 0 (30→31) taken 2 times.
✓ Branch 2 (31→32) taken 2 times.
|
2 | fs << "\t# Try loading from build directory" << std::endl; |
| 31 |
2/2✓ Branch 0 (32→33) taken 2 times.
✓ Branch 2 (33→34) taken 2 times.
|
2 | fs << "\tbuild_path = os.path.join(os.path.dirname(__file__), '..', '..', '..', 'build', 'src')" << std::endl; |
| 32 |
2/2✓ Branch 0 (34→35) taken 2 times.
✓ Branch 2 (35→36) taken 2 times.
|
2 | fs << "\tsys.path.insert(0, build_path)" << std::endl; |
| 33 |
2/2✓ Branch 0 (36→37) taken 2 times.
✓ Branch 2 (37→38) taken 2 times.
|
2 | fs << "\tprint(f\"Module search path: {build_path}\")" << std::endl; |
| 34 |
2/2✓ Branch 0 (38→39) taken 2 times.
✓ Branch 2 (39→40) taken 2 times.
|
2 | fs << "\tprint(f\"Absolute path: {os.path.abspath(build_path)}\")" << std::endl; |
| 35 |
2/2✓ Branch 0 (40→41) taken 2 times.
✓ Branch 2 (41→42) taken 2 times.
|
2 | fs << "\ttry:" << std::endl; |
| 36 |
3/3✓ Branch 0 (42→43) taken 2 times.
✓ Branch 2 (43→44) taken 2 times.
✓ Branch 4 (44→45) taken 2 times.
|
2 | fs << "\t\timport " << fileModule << std::endl; |
| 37 |
4/4✓ Branch 0 (45→46) taken 2 times.
✓ Branch 2 (46→47) taken 2 times.
✓ Branch 4 (47→48) taken 2 times.
✓ Branch 6 (48→49) taken 2 times.
|
2 | fs << "\t\tprint(\"✓ " << fileModule << " imported successfully from build!\")" << std::endl; |
| 38 |
2/2✓ Branch 0 (49→50) taken 2 times.
✓ Branch 2 (50→51) taken 2 times.
|
2 | fs << "\texcept ImportError as e:" << std::endl; |
| 39 |
2/2✓ Branch 0 (51→52) taken 2 times.
✓ Branch 2 (52→53) taken 2 times.
|
2 | fs << "\t\tprint(f\"✗ Import error: {e}\")" << std::endl; |
| 40 |
2/2✓ Branch 0 (53→54) taken 2 times.
✓ Branch 2 (54→55) taken 2 times.
|
2 | fs << "\t\tprint(\"Verifications to do:\")" << std::endl; |
| 41 |
2/2✓ Branch 0 (55→56) taken 2 times.
✓ Branch 2 (56→57) taken 2 times.
|
2 | fs << "\t\tprint(\"1. Have you compiled the project? (cmake .. && make)\")" << std::endl; |
| 42 |
2/2✓ Branch 0 (57→58) taken 2 times.
✓ Branch 2 (58→59) taken 2 times.
|
2 | fs << "\t\tprint(\"2. Does the .so file exist?\")" << std::endl; |
| 43 |
2/2✓ Branch 0 (59→60) taken 2 times.
✓ Branch 2 (60→61) taken 2 times.
|
2 | fs << "\t\tprint(f\" Check: ls -la {build_path}\")" << std::endl; |
| 44 |
3/3✓ Branch 0 (61→62) taken 2 times.
✓ Branch 2 (62→63) taken 2 times.
✓ Branch 4 (63→64) taken 2 times.
|
2 | fs << "\t\tsys.exit(1)" << std::endl << std::endl; |
| 45 | 2 | } | |
| 46 |