Skip to content

Commit e68387a

Browse files
committed
#41 fixing integration tests
1 parent a4490c2 commit e68387a

File tree

9 files changed

+70
-38
lines changed

9 files changed

+70
-38
lines changed

src/RustAnalyzer.TestAdapter/Cargo/ToolChainService.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,8 @@ public async Task<TestSuiteInfo> GetTestSuiteInfoAsync(PathEx testContainerPath,
173173
throw e;
174174
}
175175

176+
// NOTE: This will fail if two targets have the same name. Need to figure out the equivalent for fingerprint generated by the compiler
177+
// See: https://users.rust-lang.org/t/16-character-suffix-in-cargo-executable-output-names/108685/1
176178
testExeBuildInfos.ForEach(info => _tl.L.WriteLine($"GetTestSuiteInfoAsync: Figuring out which executable corresponds to '{testContainerPath}' from {info}."));
177179
var infos = testExeBuildInfos.Where(info => info.tc == testContainerPath.GetFileNameWithoutExtension());
178180
if (infos.Count() != 1)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"ThisPath": "|ROOT|\\target\\debug\\add_one.rusttests",
3+
"Manifest": "|ROOT|\\add_one\\Cargo.toml",
4+
"TargetDir": "|ROOT|\\target",
5+
"AdditionalTestDiscoveryArguments": "",
6+
"AdditionalTestExecutionArguments": "",
7+
"TestExecutionEnvironment": "",
8+
"Profile": "dev",
9+
"TestExe": "<not_yet_generated>"
10+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"ThisPath": "|ROOT|\\target\\debug\\adder.rusttests",
3+
"Manifest": "|ROOT|\\adder\\Cargo.toml",
4+
"TargetDir": "|ROOT|\\target",
5+
"AdditionalTestDiscoveryArguments": "",
6+
"AdditionalTestExecutionArguments": "",
7+
"TestExecutionEnvironment": "",
8+
"Profile": "dev",
9+
"TestExe": "<not_yet_generated>"
10+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"ThisPath": "|ROOT|\\target\\debug\\integration_tests.rusttests",
3+
"Manifest": "|ROOT|\\adder\\Cargo.toml",
4+
"TargetDir": "|ROOT|\\target",
5+
"AdditionalTestDiscoveryArguments": "",
6+
"AdditionalTestExecutionArguments": "",
7+
"TestExecutionEnvironment": "",
8+
"Profile": "dev",
9+
"TestExe": "<not_yet_generated>"
10+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"ThisPath": "|ROOT|\\target\\debug\\integration_tests_2.rusttests",
3+
"Manifest": "|ROOT|\\add_one\\Cargo.toml",
4+
"TargetDir": "|ROOT|\\target",
5+
"AdditionalTestDiscoveryArguments": "",
6+
"AdditionalTestExecutionArguments": "",
7+
"TestExecutionEnvironment": "",
8+
"Profile": "dev",
9+
"TestExe": "<not_yet_generated>"
10+
}

src/TestProjects/run-integrationtests.ps1

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ param (
66
, $TestAdapterLocation
77
)
88

9+
$TcTemplateDir = Join-Path $PSScriptRoot "integrationtests"
910
$SrcDir = Resolve-Path $SrcDir
1011
$SrcName = Split-Path $SrcDir
1112
$targetDir = Join-Path $SrcDir "target"
@@ -14,22 +15,11 @@ mkdir -Force $tcDir | Out-Null
1415
$testResults = Join-Path $SrcDir "TestResults"
1516
mkdir -Force $testResults | Out-Null
1617

17-
$testContainers = dir $SrcDir -Recurse -Filter Cargo.toml | % {
18-
$tcName = ([System.IO.Path]::GetRelativePath((Split-Path $SrcDir), (Split-Path $_)))
19-
$tcName = $tcName.Split([IO.Path]::GetInvalidFileNameChars()) -join '_'
20-
$tcPath = Join-Path $tcDir "$tcName.rusttests"
21-
$tc = @{
22-
ThisPath = $tcPath
23-
Manifest = $_.FullName
24-
TargetDir = $targetDir
25-
AdditionalTestDiscoveryArguments = ""
26-
AdditionalTestExecutionArguments = ""
27-
TestExecutionEnvironment = ""
28-
Profile = "dev"
29-
TestExe = "<not_yet_generated>"
30-
}
31-
$tcJson = ConvertTo-Json $tc
32-
$tcJson >$tcPath
18+
$testContainers = dir $TcTemplateDir -Recurse -Filter *.rusttests | % {
19+
$tcPath = Join-Path $tcDir $_.Name
20+
$tcJson = [System.IO.File]::ReadAllText($_).Replace("|ROOT|", "$SrcDir".Replace("\", "\\"))
21+
[System.IO.File]::WriteAllText($tcPath, $tcJson)
22+
3323
Write-Host -ForegroundColor Blue "TC: $tcPath"
3424
Write-Host -ForegroundColor Blue "Contents: $(gc $tcPath)"
3525
Write-Host ""
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#[test]
2+
fn integration_test_2() {
3+
assert_eq!(4, 5);
4+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#[test]
2+
fn integration_test_1() {
3+
assert_eq!(5, 5);
4+
}
Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,37 @@
1-
[Passed] tests.fibonacci_test.case_1
2-
[Passed] tests.fibonacci_test.case_1
3-
[Passed] tests.fibonacci_test.case_2
4-
[Passed] tests.fibonacci_test.case_2
5-
[Failed] tests.fibonacci_test.case_3 thread 'tests::fibonacci_test::case_3' panicked at add_one\src\lib.rs:31:9:
1+
[Passed] integration_test_1
2+
[Failed] integration_test_2 thread 'integration_test_2' panicked at add_one\tests\integration_tests_2.rs:3:5:
63
assertion `left == right` failed
7-
left: 1
8-
right: 2
4+
left: 4
5+
right: 5
96
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
107

8+
[Passed] tests.fibonacci_test.case_1
9+
[Passed] tests.fibonacci_test.case_2
1110
[Failed] tests.fibonacci_test.case_3 thread 'tests::fibonacci_test::case_3' panicked at add_one\src\lib.rs:31:9:
1211
assertion `left == right` failed
1312
left: 1
1413
right: 2
1514
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
1615

17-
[Passed] tests.it_works
18-
[Passed] tests.it_works
16+
[Passed] tests.it_works
1917
[Failed] tests.it_works_failing thread 'tests::it_works_failing' panicked at adder\src\main.rs:34:9:
2018
assertion `left == right` failed
2119
left: 3
2220
right: 5
2321

24-
[Passed] tests.it_works_passing
22+
[Passed] tests.it_works_passing
2523
[NotExecuted] tests.it_works_skipped this is a test for ignore aka skip
2624
[NotExecuted] tests.it_works245 ignored for now!
27-
[NotExecuted] tests.it_works245 ignored for now!
28-
[Passed] tests.multiplication_tests.when_both_operands_are_negative
29-
[Passed] tests.multiplication_tests.when_both_operands_are_negative
30-
[Passed] tests.multiplication_tests.when_both_operands_are_positive
31-
[Passed] tests.multiplication_tests.when_both_operands_are_positive
32-
[Passed] tests.multiplication_tests.when_operands_are_swapped
33-
[Passed] tests.multiplication_tests.when_operands_are_swapped
34-
[Passed] tests.should_fail
35-
[Passed] tests.should_fail
36-
[Passed] tests.should_success
37-
[Passed] tests.should_success
25+
[Passed] tests.multiplication_tests.when_both_operands_are_negative
26+
[Passed] tests.multiplication_tests.when_both_operands_are_positive
27+
[Passed] tests.multiplication_tests.when_operands_are_swapped
28+
[Passed] tests.should_fail
29+
[Passed] tests.should_success
3830
[Failed] tests1.tests1.it_works_failing2 thread 'tests1::tests1::it_works_failing2' panicked at adder\src\tests1.rs:20:9:
3931
assertion `left == right` failed
4032
left: 3
4133
right: 6
4234
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
4335

44-
[Passed] tests1.tests1.it_works_passing2
36+
[Passed] tests1.tests1.it_works_passing2
4537
[NotExecuted] tests1.tests1.it_works_skipped2 this is a test for ignore aka skip

0 commit comments

Comments
 (0)