Skip to content

Commit

Permalink
Report unsupported target properties as errors
Browse files Browse the repository at this point in the history
Currently, if the target declarationu uses a property that is not
supported by the target, this is reported as a warning. This is
problematic, as we and potentially users don't notice if a target
property is not supported anymore. For instance, we had several uses of
the `flags` property in the C tests although it was renamed. Also the
benchmarks used properties that we removed (See lf-lang/benchmarks-lingua-franca#61).

This PR converts the warning message into an error, adjusts the unit
tests, and fixes some of the C tests. I opted for simply dropping the
`flags` property, as apparently it wasn't required and not used for a while.
In particular, some tests attempted to avoid optimization, which is not
needed as we compile the tests in Debug mode (whithout optimization)
anyway.
  • Loading branch information
cmnrd committed Feb 23, 2024
1 parent f1cc3d2 commit 5b5c5e3
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 18 deletions.
5 changes: 2 additions & 3 deletions core/src/main/java/org/lflang/target/TargetConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,9 @@ protected void load(JsonObject jsonObject, MessageReporter messageReporter) {
* @param stage2 The second stage an the error reporter through which to report the warning.
*/
public void reportUnsupportedTargetProperty(String name, MessageReporter.Stage2 stage2) {
stage2.warning(
stage2.error(
String.format(
"The target property '%s' is not supported by the %s target and is thus ignored.",
name, this.target));
"The target property '%s' is not supported by the %s target.", name, this.target));
stage2.info("Recognized properties are: " + this.listOfRegisteredProperties());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1905,11 +1905,11 @@ public void testInvalidTargetParam() throws Exception {
var model = parseWithoutError(testCase);
List<Issue> issues = validator.validate(model);
Assertions.assertTrue(issues.size() == 2);
validator.assertWarning(
validator.assertError(
model,
LfPackage.eINSTANCE.getKeyValuePair(),
null,
"The target property 'foobarbaz' is not supported by the C target and is thus ignored.");
"The target property 'foobarbaz' is not supported by the C target.");
}

@Test
Expand All @@ -1922,12 +1922,11 @@ public void testTargetParamNotSupportedForTarget() throws Exception {
var model = parseWithoutError(testCase);
List<Issue> issues = validator.validate(model);
Assertions.assertTrue(issues.size() == 2);
validator.assertWarning(
validator.assertError(
model,
LfPackage.eINSTANCE.getKeyValuePair(),
null,
"The target property 'cargo-features' is not supported by the Python target and is thus"
+ " ignored.");
"The target property 'cargo-features' is not supported by the Python target.");
}

@Test
Expand Down
3 changes: 1 addition & 2 deletions test/C/src/concurrent/Threaded.lf
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
// that without threads, this takes more than 800 msec to complete 200 msec of logical time. See
// ThreadedMultiport for a parameterized version of this.
target C {
timeout: 2 sec,
flags: "" // Disable compiler optimization so that TakeTime actually takes time.
timeout: 2 sec
}

reactor Source {
Expand Down
3 changes: 1 addition & 2 deletions test/C/src/concurrent/ThreadedMultiport.lf
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Check multiport capabilities on Outputs.
target C {
timeout: 2 sec,
flags: "" // Disable compiler optimization so that TakeTime actually takes time.
timeout: 2 sec
}

reactor Source(width: int = 4) {
Expand Down
3 changes: 1 addition & 2 deletions test/C/src/concurrent/ThreadedThreaded.lf
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
// of this.
target C {
timeout: 2 sec,
tracing: true,
flags: "" // Disable compiler optimization so that TakeTime actually takes time.
tracing: true
}

reactor Source {
Expand Down
1 change: 0 additions & 1 deletion test/C/src/concurrent/Tracing.lf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
target C {
timeout: 2 sec,
tracing: true,
flags: "", // Disable compiler optimization so that TakeTime actually takes time.
logging: DEBUG
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* @author Edward A. Lee
*/
target C {
flags: "-Wall",
coordination: centralized,
coordination-options: {
advance-message-interval: 100 msec
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
* @author Soroush Bateni
*/
target C {
flags: "-Wall",
coordination: centralized,
coordination-options: {
advance-message-interval: 100 msec
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
* @author Soroush Bateni
*/
target C {
flags: "-Wall",
coordination: centralized,
coordination-options: {
advance-message-interval: 100 msec
Expand Down

0 comments on commit 5b5c5e3

Please sign in to comment.