Skip to content

Commit 6128498

Browse files
committed
Migrate to test item framework
1 parent 28d2611 commit 6128498

13 files changed

Lines changed: 214 additions & 390 deletions

.github/workflows/jlpkgbutler-butler-workflow.yml

Lines changed: 0 additions & 20 deletions
This file was deleted.

.github/workflows/jlpkgbutler-ci-master-workflow.yml

Lines changed: 0 additions & 40 deletions
This file was deleted.

.github/workflows/jlpkgbutler-ci-pr-workflow.yml

Lines changed: 0 additions & 38 deletions
This file was deleted.

.github/workflows/jlpkgbutler-codeformat-pr-workflow.yml

Lines changed: 0 additions & 21 deletions
This file was deleted.

.github/workflows/jlpkgbutler-compathelper-workflow.yml

Lines changed: 0 additions & 19 deletions
This file was deleted.

.github/workflows/jlpkgbutler-docdeploy-workflow.yml

Lines changed: 0 additions & 21 deletions
This file was deleted.

.github/workflows/jlpkgbutler-tagbot-workflow.yml

Lines changed: 0 additions & 13 deletions
This file was deleted.

.github/workflows/juliaci.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Julia CI
2+
3+
on:
4+
push: {branches: [main,master]}
5+
pull_request: {types: [opened,synchronize,reopened]}
6+
issue_comment: {types: [created]}
7+
schedule: [{cron: '0 0 * * *'}]
8+
workflow_dispatch: {inputs: {feature: {type: choice, description: What to run, options: [CompatHelper,DocDeploy,LintAndTest,TagBot]}}}
9+
10+
jobs:
11+
julia-ci:
12+
uses: julia-vscode/testitem-workflow/.github/workflows/juliaci.yml@v1
13+
with:
14+
include-all-compatible-minor-versions: true
15+
include-rc-versions: true
16+
permissions: write-all
17+
secrets:
18+
codecov_token: ${{ secrets.CODECOV_TOKEN }}

Project.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ IteratorInterfaceExtensions = "82899510-4779-5014-852e-03e436cf321d"
1010

1111
[extras]
1212
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
13+
TestItemRunner = "f8b46487-2199-4994-9208-9a1283c18c0a"
14+
1315

1416
[compat]
1517
julia = "1"
@@ -19,4 +21,4 @@ DataValues = "0.4.4"
1921
IteratorInterfaceExtensions = "0.1.1, 1"
2022

2123
[targets]
22-
test = ["Test"]
24+
test = ["Test", "TestItemRunner"]

test/runtests.jl

Lines changed: 3 additions & 160 deletions
Original file line numberDiff line numberDiff line change
@@ -1,164 +1,7 @@
1-
using QueryOperators
2-
using DataValues
3-
using Test
4-
5-
@testset "QueryOperators" begin
6-
7-
@testset "Core" begin
8-
9-
source_1 = [1,2,2,3,4]
10-
enum = QueryOperators.query(source_1)
11-
12-
@test collect(QueryOperators.@filter(QueryOperators.query(source_1), i->i>2)) == [3,4]
13-
14-
@test collect(QueryOperators.@map(QueryOperators.query(source_1), i->i^2)) == [1,4,4,9,16]
15-
16-
@test collect(QueryOperators.@take(enum, 2)) == [1,2]
17-
@test collect(QueryOperators.@drop(enum, 2)) == [2,3,4]
18-
@test QueryOperators.@count(enum) == 5
19-
@test QueryOperators.@count(enum, x->x%2==0) == 3
20-
21-
dropped_str = ""
22-
for i in QueryOperators.drop(enum, 2)
23-
dropped_str *= string(i)
24-
end
25-
@test dropped_str == "234"
26-
27-
dropped_str = ""
28-
for i in QueryOperators.drop(enum, 80)
29-
dropped_str *= string(i)
30-
end
31-
@test dropped_str == ""
32-
33-
taken_str = ""
34-
for i in QueryOperators.take(enum, 2)
35-
taken_str *= string(i)
36-
end
37-
@test taken_str == "12"
38-
39-
filtered_str = ""
40-
for i in QueryOperators.@filter(enum, x->x%2==0)
41-
filtered_str *= string(i)
42-
end
43-
@test filtered_str == "224"
44-
45-
filtered_str = ""
46-
for i in QueryOperators.@filter(enum, x->x>100)
47-
filtered_str *= string(i)
48-
end
49-
@test filtered_str == ""
50-
51-
@test collect(QueryOperators.@filter(enum, x->x<3)) == [1,2,2]
52-
53-
grouped = []
54-
for i in QueryOperators.@groupby(QueryOperators.query(source_1), i->i, i->i^2)
55-
push!(grouped, i)
56-
end
57-
58-
@test grouped == [[1],[4,4],[9],[16]]
59-
60-
mapped = []
61-
for i in collect(QueryOperators.@map(enum, i->i*3))
62-
push!(mapped, i)
63-
end
64-
@test mapped == [3,6,6,9,12]
65-
66-
67-
# ensure that the default value must be of the same type
68-
errored = false
69-
try
70-
QueryOperators.@default_if_empty(source_1, "string")
71-
catch
72-
errored = true
73-
end
74-
75-
@test errored == true
76-
77-
78-
# default_if_empty for regular array
79-
d = []
80-
for i in QueryOperators.@default_if_empty(source_1, 0)
81-
push!(d, i)
82-
end
83-
@test d == [1, 2, 2, 3, 4]
84-
85-
@test collect(QueryOperators.default_if_empty(DataValue{Int}[]))[1] == DataValue{Int}()
86-
@test collect(QueryOperators.default_if_empty(DataValue{Int}[], DataValue{Int}()))[1] == DataValue{Int}()
87-
88-
# passing in a NamedTuple of DataValues
89-
nt = (a=DataValue(2), b=DataValue("test"), c=DataValue(3))
90-
def = QueryOperators.default_if_empty(typeof(nt)[])
91-
@test typeof(collect(def)[1]) == typeof(nt)
92-
93-
ordered = QueryOperators.@orderby(enum, x -> -x)
94-
@test collect(ordered) == [4, 3, 2, 2, 1]
95-
96-
filtered = QueryOperators.@orderby(QueryOperators.@filter(enum, x->x%2 == 0), x->x)
97-
@test collect(filtered) == [2, 2, 4]
98-
99-
ordered = QueryOperators.@orderby_descending(enum, x -> -x)
100-
@test collect(ordered) == [1, 2, 2, 3, 4]
101-
102-
103-
desired = [[1], [2, 2, 3], [4]]
104-
grouped = QueryOperators.@groupby(enum, x -> floor(x/2), x->x)
105-
@test collect(grouped) == desired
106-
107-
group_no_macro = QueryOperators.groupby(enum, x -> floor(x/2), quote x->floor(x/2) end)
108-
@test collect(group_no_macro) == desired
109-
110-
outer = QueryOperators.query([1,2,3,4,5,6])
111-
inner = QueryOperators.query([2,3,4,5])
112-
113-
join_desired = [[3,2], [4,3], [5,4], [6,5]]
114-
@test collect(QueryOperators.@join(outer, inner, x->x, x->x+1, (i,j)->[i,j])) == join_desired
115-
116-
group_desired = [[1, Int64[]], [2, Int64[]], [3, [2]], [4, [3]], [5, [4]], [6, [5]]]
117-
@test collect(QueryOperators.@groupjoin(outer, inner, x->x, x->x+1, (i,j)->[i,j])) == group_desired
118-
119-
many_map_desired = [[1, 2], [2, 4], [2, 4], [3, 6], [4, 8]]
120-
success = collect(QueryOperators.@mapmany(enum, x->[x*2], (x,y)->[x,y])) == many_map_desired
121-
@test success # for some reason, this is required to avoid a BoundsError
122-
123-
first = QueryOperators.query([1, 2])
124-
second = [3, 4]
125-
many_map_desired = [(1,3), (1,4), (2,3), (2,4)]
126-
success = collect(QueryOperators.@mapmany(first, i->second, (x,y)->(x,y))) == many_map_desired
127-
@test success
128-
129-
ntups = QueryOperators.query([(a=1, b=2, c=3), (a=4, b=5, c=6)])
130-
131-
@test sprint(show, ntups) == """
132-
2x3 query result
133-
a │ b │ c
134-
──┼───┼──
135-
1 │ 2 │ 3
136-
4 │ 5 │ 6"""
137-
138-
@test sprint(show, enum) == """
139-
5-element query result
140-
1
141-
2
142-
2
143-
3
144-
4"""
145-
146-
147-
@test sprint((stream,data)->show(stream, "text/html", data), ntups) ==
148-
"<table><thead><tr><th>a</th><th>b</th><th>c</th></tr></thead><tbody><tr><td>1</td><td>2</td><td>3</td></tr><tr><td>4</td><td>5</td><td>6</td></tr></tbody></table>"
149-
150-
gather_result1 = QueryOperators.gather(QueryOperators.query([(US=1, EU=1, CN=1), (US=2, EU=2, CN=2), (US=3, EU=3, CN=3)]))
151-
@test sprint(show, gather_result1) == """9x2 query result\nkey │ value\n────┼──────\n:US │ 1 \n:EU │ 1 \n:CN │ 1 \n:US │ 2 \n:EU │ 2 \n:CN │ 2 \n:US │ 3 \n:EU │ 3 \n:CN │ 3 """
152-
gather_result2 = QueryOperators.gather(QueryOperators.query([(Year=2017, US=1, EU=1, CN=1), (Year=2018, US=2, EU=2, CN=2), (Year=2019, US=3, EU=3, CN=3)]), :US, :EU, :CN)
153-
@test sprint(show, gather_result2) == "9x3 query result\nYear │ key │ value\n─────┼─────┼──────\n2017 │ :US │ 1 \n2017 │ :EU │ 1 \n2017 │ :CN │ 1 \n2018 │ :US │ 2 \n2018 │ :EU │ 2 \n2018 │ :CN │ 2 \n2019 │ :US │ 3 \n2019 │ :EU │ 3 \n2019 │ :CN │ 3 "
154-
155-
@test sprint((stream,data)->show(stream, "application/vnd.dataresource+json", data), ntups) ==
156-
"{\"schema\":{\"fields\":[{\"name\":\"a\",\"type\":\"integer\"},{\"name\":\"b\",\"type\":\"integer\"},{\"name\":\"c\",\"type\":\"integer\"}]},\"data\":[{\"a\":1,\"b\":2,\"c\":3},{\"a\":4,\"b\":5,\"c\":6}]}"
157-
158-
end
1+
using TestItemRunner
1592

3+
include("test_core.jl")
1604
include("test_enumerable_unique.jl")
161-
1625
include("test_namedtupleutilities.jl")
1636

164-
end
7+
@run_package_tests

0 commit comments

Comments
 (0)