blob: 60e98c13bf05844e8fd139469a29d5017f0f9d3b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
// Author: cirakg & claude ai
// Summary: Smoke test proving the unit-test pipeline works end to end.
//
// SmokeTest: proves the unit-test pipeline works end to end: compile with
// --unit-test, run in the headless simulator, parse the results with
// tools/ciq_test_report.py. The real test suites start with milestone M2.
import Toybox.Lang;
import Toybox.Test;
// ASCII codes of the characters a version may contain.
const ASCII_DOT = 46;
const ASCII_ZERO = 48;
const ASCII_NINE = 57;
// AppInfo.VERSION must look like MAJOR.MINOR.PATCH: three non-empty runs of
// digits separated by two dots, nothing else.
(:test)
function smokeVersionIsSemver(logger as Test.Logger) as Boolean {
var dots = 0;
var digitsInPart = 0;
var chars = AppInfo.VERSION.toCharArray();
for (var i = 0; i < chars.size(); i++) {
var code = chars[i].toNumber();
if (code == ASCII_DOT) {
if (digitsInPart == 0) {
logger.error("empty part in version " + AppInfo.VERSION);
return false;
}
dots++;
digitsInPart = 0;
} else if (code >= ASCII_ZERO && code <= ASCII_NINE) {
digitsInPart++;
} else {
logger.error("unexpected character in version " + AppInfo.VERSION);
return false;
}
}
logger.debug("version " + AppInfo.VERSION);
return dots == 2 && digitsInPart > 0;
}
|