Skip to content

Commit f386f0d

Browse files
authored
fix: handle special case in 'checking tests' R CMD check step (#103)
1 parent 33b2fd7 commit f386f0d

File tree

12 files changed

+73
-49
lines changed

12 files changed

+73
-49
lines changed

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
strategy:
4848
matrix:
4949
go-version:
50-
- 1.22.0
50+
- 1.23.2
5151
steps:
5252
- name: Checkout Repo 🛎
5353
uses: actions/checkout@v4

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
- name: Setup Go 🐹
3535
uses: actions/setup-go@v5
3636
with:
37-
go-version: 1.22.0
37+
go-version: 1.23.2
3838
cache: true
3939
cache-dependency-path: go.sum
4040

@@ -91,7 +91,7 @@ jobs:
9191
needs: args
9292
uses: slsa-framework/slsa-github-generator/.github/workflows/builder_go_slsa3.yml@v1.5.0
9393
with:
94-
go-version: "1.22"
94+
go-version: "1.23"
9595
# Optional: only needed if using ldflags.
9696
evaluated-envs: "COMMIT_DATE:${{needs.args.outputs.commit-date}}, COMMIT:${{needs.args.outputs.commit}}, VERSION:${{needs.args.outputs.version}}, TREE_STATE:${{needs.args.outputs.tree-state}}"
9797
private-repository: true

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
strategy:
2626
matrix:
2727
go-version:
28-
- 1.22.0
28+
- 1.23.2
2929
defaults:
3030
run:
3131
shell: bash
@@ -92,7 +92,7 @@ jobs:
9292
strategy:
9393
matrix:
9494
go-version:
95-
- 1.22.0
95+
- 1.23.2
9696
runs-on: ubuntu-latest
9797
steps:
9898
- name: Checkout Repo 🛎

.golangci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ linters-settings:
2222
# default is false: such cases aren't reported by default.
2323
check-blank: true
2424
govet:
25-
# report about shadowed variables
26-
check-shadowing: true
25+
enable:
26+
- shadow
2727
gocyclo:
2828
# minimal code complexity to report, 30 by default
29-
min-complexity: 15
29+
min-complexity: 16
3030
maligned:
3131
# print struct with more effective memory layout or not, false by default
3232
suggest-new: true

cmd/check.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,15 @@ func parseCheckOutput(stringToParse string, singlePackageCheckInfo *[]ItemCheckI
144144
case strings.HasSuffix(trimmedNewLine, "ERROR"):
145145
checkItemType = errConst
146146
continuationOnNextLine = false
147-
case strings.HasSuffix(trimmedNewLine, "OK"):
147+
case strings.HasSuffix(trimmedNewLine, "OK") && !strings.HasPrefix(trimmedNewLine, "Comparing"):
148+
// The 'Comparing' prefix may occur in situation like the one shown below.
149+
// In that case, we ignore the 'OK' at this line, and expect to see another check status
150+
// in one of subsequent lines.
151+
// * checking tests ...
152+
// Running ‘spelling.R’
153+
// Comparing ‘spelling.Rout’ to ‘spelling.Rout.save’ ... OK
154+
// Running ‘testthat.R’
155+
// ERROR
148156
checkItemType = ""
149157
continuationOnNextLine = false
150158
}

cmd/check_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ func Test_parseCheckOutput(t *testing.T) {
6767
assert.Equal(t, allCheckInfo[7].CheckItemType, "ERROR")
6868
assert.Equal(t, allCheckInfo[7].CheckItemContent,
6969
"* checking tests ... Running ‘testthat.R’ ERROR Running the tests in ‘tests/testthat.R’ failed. ")
70+
assert.Equal(t, allCheckInfo[8].CheckItemType, "ERROR")
71+
assert.Equal(t, allCheckInfo[8].CheckItemContent,
72+
"* checking tests ... Running ‘spelling.R’ Comparing ‘spelling.Rout’ to ‘spelling.Rout.save’ ... OK Running ‘testthat.R’ ERROR Running the tests in ‘tests/testthat.R’ failed. ")
7073
}
7174

7275
func Test_getCheckedPackages(t *testing.T) {

cmd/install.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,8 +308,8 @@ func getPackagesReadyToInstall(
308308
}
309309

310310
// mapTrueLength returns the number of elements in the map for which the value is true.
311-
func mapTrueLength(m map[string]bool) uint {
312-
var trueLength uint
311+
func mapTrueLength(m map[string]bool) int {
312+
var trueLength int
313313
for _, v := range m {
314314
if v {
315315
trueLength++

cmd/install_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ func Test_mapTrueLength(t *testing.T) {
103103
m["test3"] = true
104104
m["test4"] = false
105105
m["test5"] = true
106-
assert.Equal(t, mapTrueLength(m), uint(3))
106+
assert.Equal(t, mapTrueLength(m), 3)
107107
}
108108

109109
func Test_getPackageToInstall(t *testing.T) {

cmd/root.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ var checkAllPackages bool
3838
var maxDownloadRoutines int
3939
var maxCheckRoutines int
4040
var outputReportDirectory string
41-
var numberOfWorkers uint
41+
var numberOfWorkers int
4242
var clearCache bool
4343
var includeSuggests bool
4444
var failOnError bool
@@ -141,7 +141,7 @@ for a collection of R packages that are defined in an
141141
fmt.Println(`failOnError = ` + strconv.FormatBool(failOnError))
142142
fmt.Println(`maxDownloadRoutines = ` + strconv.Itoa(maxDownloadRoutines))
143143
fmt.Println(`maxCheckRoutines = ` + strconv.Itoa(maxCheckRoutines))
144-
fmt.Println(`numberOfWorkers = ` + strconv.Itoa(int(numberOfWorkers)))
144+
fmt.Println(`numberOfWorkers = ` + strconv.Itoa(numberOfWorkers))
145145

146146
if maxDownloadRoutines < 1 {
147147
log.Warn("Maximum number of download routines set to less than 1. Setting the number to default value of 40.")
@@ -151,7 +151,7 @@ for a collection of R packages that are defined in an
151151
log.Warn("Maximum number of R CMD check routines set to less than 1. Setting the number to default value of 5.")
152152
maxCheckRoutines = 5
153153
}
154-
if int(numberOfWorkers) < 1 {
154+
if numberOfWorkers < 1 {
155155
log.Warn("Number of simultaneous installation processes should be greater than 0. Setting the default number of workers to 20.")
156156
numberOfWorkers = 20
157157
}
@@ -268,7 +268,7 @@ for a collection of R packages that are defined in an
268268
"Maximum number of concurrently running download goroutines.")
269269
rootCmd.PersistentFlags().IntVar(&maxCheckRoutines, "maxCheckRoutines", 5,
270270
"Maximum number of concurrently running R CMD check goroutines.")
271-
rootCmd.PersistentFlags().UintVar(&numberOfWorkers, "numberOfWorkers", 20,
271+
rootCmd.PersistentFlags().IntVar(&numberOfWorkers, "numberOfWorkers", 20,
272272
"Number of simultaneous installation processes.")
273273
rootCmd.PersistentFlags().BoolVar(&clearCache, "clearCache", false,
274274
"Use this flag if you want to clear scribe internal cache directory structure. This will cause "+

cmd/testdata/r_cmd_check.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,17 @@ Some error 6
5656
ERROR
5757
Running the tests in ‘tests/testthat.R’ failed.
5858
* checking PDF version of manual ... OK
59+
* checking tests ...
60+
Running ‘spelling.R’
61+
Comparing ‘spelling.Rout’ to ‘spelling.Rout.save’ ... OK
62+
Running ‘testthat.R’
63+
OK
64+
* checking tests ...
65+
Running ‘spelling.R’
66+
Comparing ‘spelling.Rout’ to ‘spelling.Rout.save’ ... OK
67+
Running ‘testthat.R’
68+
ERROR
69+
Running the tests in ‘tests/testthat.R’ failed.
5970
* checking PDF version of
6071
manual
6172
... OK

0 commit comments

Comments
 (0)