@@ -660,6 +660,30 @@ class PackageCommandTestCase: CommandsBuildProviderTestCase {
660660 }
661661 }
662662
663+ func testShowDependenciesWithTraits( ) async throws {
664+ // swift test --filter CommandsTests.PackageCommandNativeTests/testShowDependenciesWithTraits # this specific test
665+ try await fixtureXCTest ( name: " Traits " ) { fixturePath in
666+
667+ let packageRoot = fixturePath. appending ( " Example " )
668+ let ( textOutput, _) = try await self . execute ( [ " show-dependencies " , " --format=text " ] , packagePath: packageRoot)
669+ XCTAssert ( textOutput. contains ( " (traits: Package3Trait3) " ) )
670+
671+ let ( jsonOutput, _) = try await self . execute ( [ " show-dependencies " , " --format=json " ] , packagePath: packageRoot)
672+ let json = try JSON ( bytes: ByteString ( encodingAsUTF8: jsonOutput) )
673+ guard case let . dictionary( contents) = json else { XCTFail ( " unexpected result " ) ; return }
674+ guard case let . string( name) ? = contents [ " name " ] else { XCTFail ( " unexpected result " ) ; return }
675+ XCTAssertEqual ( name, " TraitsExample " )
676+
677+ // verify the traits JSON entry lists each of the traits in the fixture
678+ guard case let . string( traitsProperty) ? = contents [ " traits " ] else { XCTFail ( " unexpected result " ) ; return }
679+ XCTAssert ( traitsProperty. contains ( " Package1 " ) )
680+ XCTAssert ( traitsProperty. contains ( " Package2 " ) )
681+ XCTAssert ( traitsProperty. contains ( " Package3 " ) )
682+ XCTAssert ( traitsProperty. contains ( " Package4 " ) )
683+ XCTAssert ( traitsProperty. contains ( " BuildCondition1 " ) )
684+ }
685+ }
686+
663687 func testShowDependencies_dotFormat_sr12016( ) throws {
664688 // Confirm that SR-12016 is resolved.
665689 // See https://bugs.swift.org/browse/SR-12016
0 commit comments