55 Tests for QMB/Kernel/init.m
66 Run with: wolframscript -file QMB/Tests/InitTests.wl
77 ============================================================ *)
8-
98Get [FileNameJoin [{DirectoryName [$InputFileName ], "TestUtils.wl" }]]
10-
119RootPath = DirectoryName [DirectoryName [$InputFileName ]];
1210PacletPath = FileNameJoin [{RootPath , "PacletInfo.wl" }];
13-
14- (* ------------------------------------------------------------ *)
15- TestSection ["Step 1 \[ LongDash] ForScience paclet" ]
16-
17- Print [" Checking ForScience installation..." ];
18- VerifyProperty [
19- Length [PacletFind ["ForScience" ]] > 0 ,
20- "ForScience is installed after init"
21- ]
22-
2311(* ------------------------------------------------------------ *)
24- TestSection ["Step 2 \[ LongDash] Local version reading" ]
25-
12+ TestSection ["Step 1 \[ LongDash] Local version reading" ]
2613Print [" Checking PacletInfo.wl exists..." ];
2714VerifyProperty [
2815 FileExistsQ [PacletPath ],
2916 "PacletInfo.wl exists"
3017]
31-
3218Print [" Reading local version..." ];
33- VerifyTest [
34- Module [{data },
35- data = Import [PacletPath ];
36- Version /. List @@ data
37- ],
38- "2.4.2" ,
39- "Local version reads correctly from PacletInfo.wl"
40- ]
41-
42- Print [" Checking local version type..." ];
43- VerifyProperty [
44- StringQ [Version /. List @@ Import [PacletPath ]],
45- "Local version is a String"
46- ]
47-
48- (* ------------------------------------------------------------ *)
49- TestSection ["Step 3 \[ LongDash] Remote version check" ]
50-
51- Print [" Fetching remote version.txt (timeout: 3s)..." ];
52- VerifyProperty [
53- StringQ [Quiet [TimeConstrained [
54- URLRead [
55- "https://raw.githubusercontent.com/deleonja/libs/main/QMB/version.txt" ,
56- "Body"
57- ],
58- 3 , $Failed
59- ]]],
60- "Remote version.txt is reachable within 3s"
61- ]
62-
63- Print [" Validating remote version format..." ];
6419VerifyProperty [
6520 StringMatchQ [
66- StringTrim @ Quiet [TimeConstrained [
67- URLRead [
68- "https://raw.githubusercontent.com/deleonja/libs/main/QMB/version.txt" ,
69- "Body"
70- ],
71- 3 , $Failed
72- ]],
21+ Module [{data }, Version /. List @@ Import [PacletPath ]],
7322 DigitCharacter .. ~~ "." ~~ DigitCharacter .. ~~ "." ~~ DigitCharacter ..
7423 ],
75- "Remote version has valid semver format X.Y.Z"
76- ]
77-
78- (* ------------------------------------------------------------ *)
79- TestSection ["Step 3 \[ LongDash] Timeout fallback" ]
80-
81- Print [" Simulating network timeout (may take up to 3s)..." ];
82- VerifyTest [
83- Quiet [TimeConstrained [
84- URLRead ["http://192.0.2.1" , "Body" ],
85- 3 , $Failed
86- ]],
87- $Failed ,
88- "Returns $Failed when timeout is exceeded"
24+ "Local version has valid semver format X.Y.Z"
8925]
90-
9126(* ------------------------------------------------------------ *)
92- TestSection ["Step 4 \[ LongDash] Version comparison" ]
93-
94- Print [" Checking =!= detects mismatch..." ];
95- VerifyProperty [
96- ("2.4.2" =!= "2.4.0" ),
97- "=!= correctly detects version mismatch"
98- ]
99-
100- Print [" Checking =!= detects match..." ];
101- VerifyProperty [
102- ! ("2.4.2" =!= "2.4.2" ),
103- "=!= correctly detects matching versions"
104- ]
105-
106- (* ------------------------------------------------------------ *)
107- TestSection ["Step 5 \[ LongDash] Submodules load correctly" ]
108-
27+ TestSection ["Step 2 \[ LongDash] Submodules load correctly" ]
10928submodules = {
11029 "OldQMB.wl" ,
11130 "GeneralQM.wl" ,
@@ -115,7 +34,6 @@ submodules = {
11534 FileNameJoin [{"ManyBody" , "BoseHubbard.wl" }],
11635 FileNameJoin [{"ManyBody" , "Fermions.wl" }]
11736};
118-
11937Print [" Checking submodules exist on disk..." ];
12038Scan [
12139 Function [sub ,
12745 ],
12846 submodules
12947]
130-
13148Print [" Loading init.m..." ];
13249VerifyProperty [
13350 Quiet [Check [
@@ -136,6 +53,5 @@ VerifyProperty[
13653 ]] =!= $Failed ,
13754 "init.m loads without errors"
13855]
139-
14056(* ------------------------------------------------------------ *)
14157PrintTestSummary []
0 commit comments