Skip to content

Commit

Permalink
Do not lint platforms for default on subports
Browse files Browse the repository at this point in the history
The check that platforms isn't equal to darwin is not performed on a subport
as there is a specific logic for subports.

Closes: https://trac.macports.org/ticket/70997
  • Loading branch information
pguyot committed Nov 23, 2024
1 parent 1bc12af commit 14b9000
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/port1.0/portlint.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ proc portlint::lint_platforms {platforms} {
set errors [list]
set warnings [list]

global lint_platforms
global lint_platforms subport name

foreach platform $platforms {
set platname [lindex $platform 0]
Expand All @@ -269,7 +269,7 @@ proc portlint::lint_platforms {platforms} {
}
}

if {$platforms eq "darwin"} {
if {$platforms eq "darwin" && [string equal -nocase $name $subport]} {
lappend warnings "Unnecessary platforms line as darwin is the default"
}

Expand Down
27 changes: 27 additions & 0 deletions src/port1.0/tests/portlint.test
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,8 @@ test test_lint_platforms_succeeds_with_darwin_freebsd {
Verify that platforms is accepted with darwin freebsd
} -body {
set platforms "darwin freebsd"
set name "test"
set subport "test"
set results [portlint::lint_platforms $platforms]
set err_results [lindex $results 0]
set warn_results [lindex $results 1]
Expand All @@ -666,6 +668,8 @@ test test_lint_platforms_succeeds_with_freebsd {
Verify that platforms is accepted with freebsd
} -body {
set platforms "freebsd"
set name "test"
set subport "test"
set results [portlint::lint_platforms $platforms]
set err_results [lindex $results 0]
set warn_results [lindex $results 1]
Expand All @@ -683,6 +687,8 @@ test test_lint_platforms_fails_with_msdos {
Verify that platforms fails with msdos as this is unknown
} -body {
set platforms "msdos"
set name "test"
set subport "test"
set results [portlint::lint_platforms $platforms]
set err_results [lindex $results 0]
set warn_results [lindex $results 1]
Expand All @@ -700,6 +706,8 @@ test test_lint_platforms_fails_with_darwin {
Verify that platforms fails with darwin as this is the default
} -body {
set platforms "darwin"
set name "test"
set subport "test"
set results [portlint::lint_platforms $platforms]
set err_results [lindex $results 0]
set warn_results [lindex $results 1]
Expand All @@ -713,4 +721,23 @@ test test_lint_platforms_fails_with_darwin {
return "lint_platforms_darwin_fails passed"
} -result "lint_platforms_darwin_fails passed"

test test_lint_platforms_succeeds_with_subports {
Verify that platforms succeeds with subports
} -body {
set platforms "darwin"
set name "test"
set subport "subport"
set results [portlint::lint_platforms $platforms]
set err_results [lindex $results 0]
set warn_results [lindex $results 1]

if {[llength $warn_results] > 0} {
return "FAIL: unexpected error results"
}
if {[llength $err_results] > 0} {
return "FAIL: unexpected error results"
}
return "test_lint_platforms_succeeds_with_subports passed"
} -result "test_lint_platforms_succeeds_with_subports passed"

cleanupTests

0 comments on commit 14b9000

Please sign in to comment.