Skip to content

Commit 8d12353

Browse files
committed
Integration tests support should mostly be done, minus bug fixes
1 parent c55479c commit 8d12353

22 files changed

+428
-215
lines changed
Lines changed: 179 additions & 136 deletions
Original file line numberDiff line numberDiff line change
@@ -1,138 +1,181 @@
1-
{
2-
"source": "<TestRoot>\\hello_library\\target\\release\\hello_lib_libhello_lib.rusttests",
3-
"exe": "<TestRoot>\\hello_library\\target\\release\\deps\\hello_lib-d9d78f0fcd1af879.exe",
4-
"tests": [
5-
{
6-
"type": "test",
7-
"name": "tests::fibonacci_test::case_1",
8-
"ignore": false,
9-
"ignore_message": "",
10-
"source_path": "<TestRoot>\\hello_library\\src\\lib.rs",
11-
"start_line": 32,
12-
"start_col": 8,
13-
"end_line": 32,
14-
"end_col": 22
1+
[
2+
{
3+
"container": {
4+
"ThisPath": "<TestRoot>\\hello_library\\target\\release\\hello_lib_libhello_lib.rusttests",
5+
"Manifest": "<TestRoot>\\hello_library\\Cargo.toml",
6+
"TargetDir": "<TestRoot>\\hello_library\\target",
7+
"AdditionalTestDiscoveryArguments": "",
8+
"AdditionalTestExecutionArguments": "",
9+
"TestExecutionEnvironment": "",
10+
"Profile": "release",
11+
"TestExes": [
12+
"<TestRoot>\\hello_library\\target\\release\\deps\\hello_lib-d9d78f0fcd1af879.exe",
13+
"<TestRoot>\\hello_library\\target\\release\\deps\\int_tests-58f9d629627e8abd.exe"
14+
]
1515
},
16-
{
17-
"type": "test",
18-
"name": "tests::fibonacci_test::case_2",
19-
"ignore": false,
20-
"ignore_message": "",
21-
"source_path": "<TestRoot>\\hello_library\\src\\lib.rs",
22-
"start_line": 32,
23-
"start_col": 8,
24-
"end_line": 32,
25-
"end_col": 22
16+
"exe": "<TestRoot>\\hello_library\\target\\release\\deps\\hello_lib-d9d78f0fcd1af879.exe",
17+
"tests": [
18+
{
19+
"type": "test",
20+
"name": "tests::fibonacci_test::case_1",
21+
"ignore": false,
22+
"ignore_message": "",
23+
"source_path": "<TestRoot>\\hello_library\\src\\lib.rs",
24+
"start_line": 32,
25+
"start_col": 8,
26+
"end_line": 32,
27+
"end_col": 22
28+
},
29+
{
30+
"type": "test",
31+
"name": "tests::fibonacci_test::case_2",
32+
"ignore": false,
33+
"ignore_message": "",
34+
"source_path": "<TestRoot>\\hello_library\\src\\lib.rs",
35+
"start_line": 32,
36+
"start_col": 8,
37+
"end_line": 32,
38+
"end_col": 22
39+
},
40+
{
41+
"type": "test",
42+
"name": "tests::fibonacci_test::case_3",
43+
"ignore": false,
44+
"ignore_message": "",
45+
"source_path": "<TestRoot>\\hello_library\\src\\lib.rs",
46+
"start_line": 32,
47+
"start_col": 8,
48+
"end_line": 32,
49+
"end_col": 22
50+
},
51+
{
52+
"type": "test",
53+
"name": "tests::it_works",
54+
"ignore": false,
55+
"ignore_message": "",
56+
"source_path": "<TestRoot>\\hello_library\\src\\lib.rs",
57+
"start_line": 17,
58+
"start_col": 8,
59+
"end_line": 17,
60+
"end_col": 16
61+
},
62+
{
63+
"type": "test",
64+
"name": "tests::it_works245_ignored",
65+
"ignore": true,
66+
"ignore_message": "ignored for now!",
67+
"source_path": "<TestRoot>\\hello_library\\src\\lib.rs",
68+
"start_line": 24,
69+
"start_col": 8,
70+
"end_line": 24,
71+
"end_col": 27
72+
},
73+
{
74+
"type": "test",
75+
"name": "tests::long_running_test",
76+
"ignore": false,
77+
"ignore_message": "",
78+
"source_path": "<TestRoot>\\hello_library\\src\\lib.rs",
79+
"start_line": 66,
80+
"start_col": 8,
81+
"end_line": 66,
82+
"end_col": 25
83+
},
84+
{
85+
"type": "test",
86+
"name": "tests::multiplication_tests::when_both_operands_are_negative",
87+
"ignore": false,
88+
"ignore_message": "",
89+
"source_path": "<TestRoot>\\hello_library\\src\\lib.rs",
90+
"start_line": 51,
91+
"start_col": 5,
92+
"end_line": 51,
93+
"end_col": 61
94+
},
95+
{
96+
"type": "test",
97+
"name": "tests::multiplication_tests::when_both_operands_are_positive",
98+
"ignore": false,
99+
"ignore_message": "",
100+
"source_path": "<TestRoot>\\hello_library\\src\\lib.rs",
101+
"start_line": 51,
102+
"start_col": 5,
103+
"end_line": 51,
104+
"end_col": 61
105+
},
106+
{
107+
"type": "test",
108+
"name": "tests::multiplication_tests::when_operands_are_swapped",
109+
"ignore": false,
110+
"ignore_message": "",
111+
"source_path": "<TestRoot>\\hello_library\\src\\lib.rs",
112+
"start_line": 51,
113+
"start_col": 5,
114+
"end_line": 51,
115+
"end_col": 61
116+
},
117+
{
118+
"type": "test",
119+
"name": "tests::mytest",
120+
"ignore": false,
121+
"ignore_message": "",
122+
"source_path": "<TestRoot>\\hello_library\\src\\lib.rs",
123+
"start_line": 61,
124+
"start_col": 8,
125+
"end_line": 61,
126+
"end_col": 14
127+
},
128+
{
129+
"type": "test",
130+
"name": "tests::should_fail",
131+
"ignore": false,
132+
"ignore_message": "",
133+
"source_path": "<TestRoot>\\hello_library\\src\\lib.rs",
134+
"start_line": 47,
135+
"start_col": 8,
136+
"end_line": 47,
137+
"end_col": 19
138+
},
139+
{
140+
"type": "test",
141+
"name": "tests::should_success",
142+
"ignore": false,
143+
"ignore_message": "",
144+
"source_path": "<TestRoot>\\hello_library\\src\\lib.rs",
145+
"start_line": 42,
146+
"start_col": 8,
147+
"end_line": 42,
148+
"end_col": 22
149+
}
150+
]
151+
},
152+
{
153+
"container": {
154+
"ThisPath": "<TestRoot>\\hello_library\\target\\release\\hello_lib_libhello_lib.rusttests",
155+
"Manifest": "<TestRoot>\\hello_library\\Cargo.toml",
156+
"TargetDir": "<TestRoot>\\hello_library\\target",
157+
"AdditionalTestDiscoveryArguments": "",
158+
"AdditionalTestExecutionArguments": "",
159+
"TestExecutionEnvironment": "",
160+
"Profile": "release",
161+
"TestExes": [
162+
"<TestRoot>\\hello_library\\target\\release\\deps\\hello_lib-d9d78f0fcd1af879.exe",
163+
"<TestRoot>\\hello_library\\target\\release\\deps\\int_tests-58f9d629627e8abd.exe"
164+
]
26165
},
27-
{
28-
"type": "test",
29-
"name": "tests::fibonacci_test::case_3",
30-
"ignore": false,
31-
"ignore_message": "",
32-
"source_path": "<TestRoot>\\hello_library\\src\\lib.rs",
33-
"start_line": 32,
34-
"start_col": 8,
35-
"end_line": 32,
36-
"end_col": 22
37-
},
38-
{
39-
"type": "test",
40-
"name": "tests::it_works",
41-
"ignore": false,
42-
"ignore_message": "",
43-
"source_path": "<TestRoot>\\hello_library\\src\\lib.rs",
44-
"start_line": 17,
45-
"start_col": 8,
46-
"end_line": 17,
47-
"end_col": 16
48-
},
49-
{
50-
"type": "test",
51-
"name": "tests::it_works245_ignored",
52-
"ignore": true,
53-
"ignore_message": "ignored for now!",
54-
"source_path": "<TestRoot>\\hello_library\\src\\lib.rs",
55-
"start_line": 24,
56-
"start_col": 8,
57-
"end_line": 24,
58-
"end_col": 27
59-
},
60-
{
61-
"type": "test",
62-
"name": "tests::long_running_test",
63-
"ignore": false,
64-
"ignore_message": "",
65-
"source_path": "<TestRoot>\\hello_library\\src\\lib.rs",
66-
"start_line": 66,
67-
"start_col": 8,
68-
"end_line": 66,
69-
"end_col": 25
70-
},
71-
{
72-
"type": "test",
73-
"name": "tests::multiplication_tests::when_both_operands_are_negative",
74-
"ignore": false,
75-
"ignore_message": "",
76-
"source_path": "<TestRoot>\\hello_library\\src\\lib.rs",
77-
"start_line": 51,
78-
"start_col": 5,
79-
"end_line": 51,
80-
"end_col": 61
81-
},
82-
{
83-
"type": "test",
84-
"name": "tests::multiplication_tests::when_both_operands_are_positive",
85-
"ignore": false,
86-
"ignore_message": "",
87-
"source_path": "<TestRoot>\\hello_library\\src\\lib.rs",
88-
"start_line": 51,
89-
"start_col": 5,
90-
"end_line": 51,
91-
"end_col": 61
92-
},
93-
{
94-
"type": "test",
95-
"name": "tests::multiplication_tests::when_operands_are_swapped",
96-
"ignore": false,
97-
"ignore_message": "",
98-
"source_path": "<TestRoot>\\hello_library\\src\\lib.rs",
99-
"start_line": 51,
100-
"start_col": 5,
101-
"end_line": 51,
102-
"end_col": 61
103-
},
104-
{
105-
"type": "test",
106-
"name": "tests::mytest",
107-
"ignore": false,
108-
"ignore_message": "",
109-
"source_path": "<TestRoot>\\hello_library\\src\\lib.rs",
110-
"start_line": 61,
111-
"start_col": 8,
112-
"end_line": 61,
113-
"end_col": 14
114-
},
115-
{
116-
"type": "test",
117-
"name": "tests::should_fail",
118-
"ignore": false,
119-
"ignore_message": "",
120-
"source_path": "<TestRoot>\\hello_library\\src\\lib.rs",
121-
"start_line": 47,
122-
"start_col": 8,
123-
"end_line": 47,
124-
"end_col": 19
125-
},
126-
{
127-
"type": "test",
128-
"name": "tests::should_success",
129-
"ignore": false,
130-
"ignore_message": "",
131-
"source_path": "<TestRoot>\\hello_library\\src\\lib.rs",
132-
"start_line": 42,
133-
"start_col": 8,
134-
"end_line": 42,
135-
"end_col": 22
136-
}
137-
]
138-
}
166+
"exe": "<TestRoot>\\hello_library\\target\\release\\deps\\int_tests-58f9d629627e8abd.exe",
167+
"tests": [
168+
{
169+
"type": "test",
170+
"name": "tests::int_test_1",
171+
"ignore": false,
172+
"ignore_message": "",
173+
"source_path": "<TestRoot>\\hello_library\\tests\\int_tests.rs",
174+
"start_line": 4,
175+
"start_col": 8,
176+
"end_line": 4,
177+
"end_col": 18
178+
}
179+
]
180+
}
181+
]
Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
1-
{
2-
"source": "<TestRoot>\\hello_world\\target\\release\\hello_world_hello_world.rusttests",
3-
"exe": "<TestRoot>\\hello_world\\target\\release\\deps\\hello_world-d116900458eb29b6.exe",
4-
"tests": []
5-
}
1+
[
2+
{
3+
"container": {
4+
"ThisPath": "<TestRoot>\\hello_world\\target\\release\\hello_world_hello_world.rusttests",
5+
"Manifest": "<TestRoot>\\hello_world\\Cargo.toml",
6+
"TargetDir": "<TestRoot>\\hello_world\\target",
7+
"AdditionalTestDiscoveryArguments": "",
8+
"AdditionalTestExecutionArguments": "",
9+
"TestExecutionEnvironment": "",
10+
"Profile": "release",
11+
"TestExes": [
12+
"<TestRoot>\\hello_world\\target\\release\\deps\\hello_world-d116900458eb29b6.exe"
13+
]
14+
},
15+
"exe": "<TestRoot>\\hello_world\\target\\release\\deps\\hello_world-d116900458eb29b6.exe",
16+
"tests": []
17+
}
18+
]

src/RustAnalyzer.TestAdapter.UnitTests/Cargo/ToolChainServiceTests.cs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,10 @@ public async Task AdditionalBuildArgsTestsAsync(string workspaceRelRoot, string
113113
}
114114

115115
[Theory]
116-
[InlineData(@"hello_world", "hello_world_hello_world.rusttests", "release")] // No tests.
117-
[InlineData(@"hello_library", "hello_lib_libhello_lib.rusttests", "release")] // Has tests.
116+
[InlineData(@"hello_world", "hello_world_hello_world.rusttests", "release", new string[] { "hello_world-d116900458eb29b6.exe" })] // No tests.
117+
[InlineData(@"hello_library", "hello_lib_libhello_lib.rusttests", "release", new[] { "hello_lib-d9d78f0fcd1af879.exe", "int_tests-58f9d629627e8abd.exe" })] // Has tests.
118118
[UseReporter(typeof(RaVsDiffReporter))]
119-
public async Task GetTestSuiteTestsAsync(string workspaceRelRoot, string containerName, string profile)
119+
public async Task GetTestSuiteTestsAsync(string workspaceRelRoot, string containerName, string profile, string[] testExes)
120120
{
121121
NamerFactory.AdditionalInformation = workspaceRelRoot.ReplaceInvalidChars();
122122
var workspacePath = TestHelpers.ThisTestRoot + (PathEx)workspaceRelRoot;
@@ -125,15 +125,16 @@ public async Task GetTestSuiteTestsAsync(string workspaceRelRoot, string contain
125125
var tcPath = targetPath + (PathEx)containerName;
126126

127127
await _tcs.DoBuildAsync(workspacePath, manifestPath, profile);
128-
var testSuite = await _tcs.GetTestSuiteInfoAsync(tcPath, profile, default);
128+
var testSuites = await _tcs.GetTestSuiteInfoAsync(tcPath, profile, default).ToArrayAsync();
129129
var tc = JsonConvert.DeserializeObject<TestContainer>(await tcPath.ReadAllTextAsync(default));
130130

131-
tc.TestExes[0].FileExists().Should().BeTrue();
132-
tc.TestExes[0].GetExtension().Should().Be((PathEx)".exe");
131+
tc.TestExes.All(e => e.FileExists()).Should().BeTrue();
132+
tc.TestExes.Select(e => e.GetFileName()).Should().BeEquivalentTo(testExes.Select(e => (PathEx)e));
133133
tc.Profile.Should().Be(profile);
134134
tc.ThisPath.Should().Be(tcPath);
135-
testSuite.Source.Should().Be(tcPath);
136-
var normalizedStr = testSuite.SerializeAndNormalizeObject();
135+
testSuites.Should().HaveCount(testExes.Length);
136+
testSuites.Select(x => x.Container.ThisPath).Should().OnlyContain(x => x == tcPath);
137+
var normalizedStr = testSuites.SerializeAndNormalizeObject();
137138
Approvals.Verify(normalizedStr);
138139
}
139140
}

src/RustAnalyzer.TestAdapter.UnitTests/TestDiscovererTests.DiscoverTestsTestsAsync.hello_library.approved.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,5 +118,15 @@
118118
"CodeFilePath": "<TestRoot>\\hello_library\\src\\lib.rs",
119119
"LineNumber": 42,
120120
"Properties": []
121+
},
122+
{
123+
"Id": "6d251830-b822-840b-1c4d-7b80f05e7f83",
124+
"FullyQualifiedName": "int_tests.tests.int_test_1",
125+
"DisplayName": "int_test_1",
126+
"ExecutorUri": "executor://RustTestExecutor/v1",
127+
"Source": "<TestRoot>\\hello_library\\target\\debug\\hello_lib_libhello_lib.rusttests",
128+
"CodeFilePath": "<TestRoot>\\hello_library\\tests\\int_tests.rs",
129+
"LineNumber": 4,
130+
"Properties": []
121131
}
122132
]

0 commit comments

Comments
 (0)