@@ -1214,6 +1214,55 @@ mod tests {
12141214 assert ! ( result. contains( "15 tests passed" ) ) ;
12151215 }
12161216
1217+ #[ test]
1218+ fn test_filter_package_token_savings ( ) {
1219+ let input = r#"[INFO] Scanning for projects...
1220+ [INFO]
1221+ [INFO] -----------------------< com.example:myapp >------------------------
1222+ [INFO] Building myapp 1.0-SNAPSHOT
1223+ [INFO] --------------------------------[ jar ]---------------------------------
1224+ [INFO]
1225+ [INFO] --- maven-resources-plugin:3.3.1:resources (default-resources) @ myapp ---
1226+ [INFO] Copying 5 resources from src/main/resources to target/classes
1227+ [INFO]
1228+ [INFO] --- maven-compiler-plugin:3.11.0:compile (default-compile) @ myapp ---
1229+ [INFO] Compiling 42 source files to /home/user/myapp/target/classes
1230+ [INFO]
1231+ [INFO] --- maven-resources-plugin:3.3.1:testResources (default-testResources) @ myapp ---
1232+ [INFO] Copying 2 resources from src/test/resources to target/test-classes
1233+ [INFO]
1234+ [INFO] --- maven-compiler-plugin:3.11.0:testCompile (default-testCompile) @ myapp ---
1235+ [INFO] Compiling 15 source files to /home/user/myapp/target/test-classes
1236+ [INFO]
1237+ [INFO] --- maven-surefire-plugin:3.1.2:test (default-test) @ myapp ---
1238+ [INFO] Using auto detected provider org.apache.maven.surefire.junitplatform.JUnitPlatformProvider
1239+ [INFO] Tests run: 15, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.234 s
1240+ [INFO]
1241+ [INFO] Results:
1242+ [INFO]
1243+ [INFO] Tests run: 15, Failures: 0, Errors: 0, Skipped: 0
1244+ [INFO]
1245+ [INFO] --- maven-jar-plugin:3.3.0:jar (default-jar) @ myapp ---
1246+ [INFO] Building jar: /home/user/myapp/target/myapp-1.0-SNAPSHOT.jar
1247+ [INFO]
1248+ [INFO] ------------------------------------------------------------------------
1249+ [INFO] BUILD SUCCESS
1250+ [INFO] ------------------------------------------------------------------------
1251+ [INFO] Total time: 12.345 s
1252+ [INFO] Finished at: 2024-01-15T10:30:00Z
1253+ [INFO] ------------------------------------------------------------------------"# ;
1254+
1255+ let output = filter_mvn_package ( input) ;
1256+ let input_tokens = count_tokens ( input) ;
1257+ let output_tokens = count_tokens ( & output) ;
1258+ let savings = 100.0 - ( output_tokens as f64 / input_tokens as f64 * 100.0 ) ;
1259+ assert ! (
1260+ savings >= 60.0 ,
1261+ "Package filter: expected ≥60% savings, got {:.1}%" ,
1262+ savings
1263+ ) ;
1264+ }
1265+
12171266 // ── Install filter tests ──
12181267
12191268 #[ test]
@@ -1250,6 +1299,52 @@ mod tests {
12501299 assert ! ( result. contains( "15 tests passed" ) ) ;
12511300 }
12521301
1302+ #[ test]
1303+ fn test_filter_install_token_savings ( ) {
1304+ let input = r#"[INFO] Scanning for projects...
1305+ [INFO]
1306+ [INFO] -----------------------< com.example:myapp >------------------------
1307+ [INFO] Building myapp 1.0-SNAPSHOT
1308+ [INFO] --------------------------------[ jar ]---------------------------------
1309+ [INFO]
1310+ [INFO] --- maven-resources-plugin:3.3.1:resources (default-resources) @ myapp ---
1311+ [INFO] Copying 5 resources from src/main/resources to target/classes
1312+ [INFO]
1313+ [INFO] --- maven-compiler-plugin:3.11.0:compile (default-compile) @ myapp ---
1314+ [INFO] Compiling 42 source files to /home/user/myapp/target/classes
1315+ [INFO]
1316+ [INFO] --- maven-surefire-plugin:3.1.2:test (default-test) @ myapp ---
1317+ [INFO] Tests run: 15, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.234 s
1318+ [INFO]
1319+ [INFO] Results:
1320+ [INFO]
1321+ [INFO] Tests run: 15, Failures: 0, Errors: 0, Skipped: 0
1322+ [INFO]
1323+ [INFO] --- maven-jar-plugin:3.3.0:jar (default-jar) @ myapp ---
1324+ [INFO] Building jar: /home/user/myapp/target/myapp-1.0-SNAPSHOT.jar
1325+ [INFO]
1326+ [INFO] --- maven-install-plugin:3.1.1:install (default-install) @ myapp ---
1327+ [INFO] Installing /home/user/myapp/target/myapp-1.0-SNAPSHOT.jar to /home/user/.m2/repository/com/example/myapp/1.0-SNAPSHOT/myapp-1.0-SNAPSHOT.jar
1328+ [INFO] Installing /home/user/myapp/pom.xml to /home/user/.m2/repository/com/example/myapp/1.0-SNAPSHOT/myapp-1.0-SNAPSHOT.pom
1329+ [INFO]
1330+ [INFO] ------------------------------------------------------------------------
1331+ [INFO] BUILD SUCCESS
1332+ [INFO] ------------------------------------------------------------------------
1333+ [INFO] Total time: 15.678 s
1334+ [INFO] Finished at: 2024-01-15T10:30:00Z
1335+ [INFO] ------------------------------------------------------------------------"# ;
1336+
1337+ let output = filter_mvn_install ( input) ;
1338+ let input_tokens = count_tokens ( input) ;
1339+ let output_tokens = count_tokens ( & output) ;
1340+ let savings = 100.0 - ( output_tokens as f64 / input_tokens as f64 * 100.0 ) ;
1341+ assert ! (
1342+ savings >= 60.0 ,
1343+ "Install filter: expected ≥60% savings, got {:.1}%" ,
1344+ savings
1345+ ) ;
1346+ }
1347+
12531348 // ── Dependency tree filter tests ──
12541349
12551350 #[ test]
@@ -1529,6 +1624,183 @@ mod tests {
15291624 assert ! ( warnings. iter( ) . any( |w| w. contains( "(x3)" ) ) ) ;
15301625 }
15311626
1627+ // ── Integration-test filter tests ──
1628+
1629+ #[ test]
1630+ fn test_filter_integration_test_failsafe_warning ( ) {
1631+ // Simulate Failsafe output with BUILD SUCCESS
1632+ let raw = r#"[INFO] Scanning for projects...
1633+ [INFO]
1634+ [INFO] --- maven-failsafe-plugin:3.1.2:integration-test (default) @ myapp ---
1635+ [INFO] Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 5.0 s
1636+ [INFO]
1637+ [INFO] Results:
1638+ [INFO]
1639+ [INFO] Tests run: 3, Failures: 0, Errors: 0, Skipped: 0
1640+ [INFO]
1641+ [INFO] ------------------------------------------------------------------------
1642+ [INFO] BUILD SUCCESS
1643+ [INFO] ------------------------------------------------------------------------
1644+ [INFO] Total time: 8.0 s"# ;
1645+
1646+ // run_integration_test uses this closure
1647+ let filtered = filter_mvn_test ( raw) ;
1648+ let result = if raw. contains ( "BUILD SUCCESS" )
1649+ && ( raw. contains ( "failsafe" ) || raw. contains ( "Failsafe" ) )
1650+ {
1651+ format ! (
1652+ "{}\n \n note: Failsafe defers failure reporting to `mvn verify`.\n \
1653+ Use `rtk mvn verify` for accurate integration-test results.",
1654+ filtered
1655+ )
1656+ } else {
1657+ filtered
1658+ } ;
1659+
1660+ assert ! ( result. contains( "3 passed" ) ) ;
1661+ assert ! ( result. contains( "Failsafe defers" ) ) ;
1662+ assert ! ( result. contains( "rtk mvn verify" ) ) ;
1663+ }
1664+
1665+ #[ test]
1666+ fn test_filter_integration_test_no_failsafe_no_warning ( ) {
1667+ // Surefire-only output — no failsafe warning
1668+ let raw = r#"[INFO] --- maven-surefire-plugin:3.1.2:test (default-test) @ myapp ---
1669+ [INFO] Tests run: 5, Failures: 0, Errors: 0, Skipped: 0
1670+ [INFO] BUILD SUCCESS
1671+ [INFO] Total time: 3.0 s"# ;
1672+
1673+ let filtered = filter_mvn_test ( raw) ;
1674+ let result = if raw. contains ( "BUILD SUCCESS" )
1675+ && ( raw. contains ( "failsafe" ) || raw. contains ( "Failsafe" ) )
1676+ {
1677+ format ! ( "{}\n \n note: Failsafe defers..." , filtered)
1678+ } else {
1679+ filtered
1680+ } ;
1681+
1682+ assert ! ( result. contains( "5 passed" ) ) ;
1683+ assert ! ( !result. contains( "Failsafe" ) ) ;
1684+ }
1685+
1686+ #[ test]
1687+ fn test_filter_integration_test_token_savings ( ) {
1688+ let input = r#"[INFO] Scanning for projects...
1689+ [INFO]
1690+ [INFO] -----------------------< com.example:myapp >------------------------
1691+ [INFO] Building myapp 1.0-SNAPSHOT
1692+ [INFO] --------------------------------[ jar ]---------------------------------
1693+ [INFO]
1694+ [INFO] --- maven-compiler-plugin:3.11.0:compile (default-compile) @ myapp ---
1695+ [INFO] Nothing to compile - all classes are up to date
1696+ [INFO]
1697+ [INFO] --- maven-failsafe-plugin:3.1.2:integration-test (default) @ myapp ---
1698+ [INFO] Using auto detected provider org.apache.maven.surefire.junitplatform.JUnitPlatformProvider
1699+ [INFO]
1700+ [INFO] -------------------------------------------------------
1701+ [INFO] T E S T S
1702+ [INFO] -------------------------------------------------------
1703+ [INFO] Running com.example.IntegrationTest
1704+ [INFO] Tests run: 8, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 12.345 s
1705+ [INFO]
1706+ [INFO] Results:
1707+ [INFO]
1708+ [INFO] Tests run: 8, Failures: 0, Errors: 0, Skipped: 0
1709+ [INFO]
1710+ [INFO] ------------------------------------------------------------------------
1711+ [INFO] BUILD SUCCESS
1712+ [INFO] ------------------------------------------------------------------------
1713+ [INFO] Total time: 18.456 s
1714+ [INFO] Finished at: 2024-01-15T10:30:00Z
1715+ [INFO] ------------------------------------------------------------------------"# ;
1716+
1717+ let output = filter_mvn_test ( input) ;
1718+ let input_tokens = count_tokens ( input) ;
1719+ let output_tokens = count_tokens ( & output) ;
1720+ let savings = 100.0 - ( output_tokens as f64 / input_tokens as f64 * 100.0 ) ;
1721+ assert ! (
1722+ savings >= 60.0 ,
1723+ "Integration-test filter: expected ≥60% savings, got {:.1}%" ,
1724+ savings
1725+ ) ;
1726+ }
1727+
1728+ // ── Snapshot-style exact output tests ──
1729+
1730+ #[ test]
1731+ fn test_filter_compile_success_exact_output ( ) {
1732+ let input = r#"[INFO] Scanning for projects...
1733+ [INFO] -----------------------< com.example:myapp >------------------------
1734+ [INFO] Building myapp 1.0-SNAPSHOT
1735+ [INFO] --------------------------------[ jar ]---------------------------------
1736+ [INFO] --- maven-compiler-plugin:3.11.0:compile (default-compile) @ myapp ---
1737+ [INFO] Compiling 42 source files to /home/user/myapp/target/classes
1738+ [INFO] ------------------------------------------------------------------------
1739+ [INFO] BUILD SUCCESS
1740+ [INFO] ------------------------------------------------------------------------
1741+ [INFO] Total time: 3.456 s
1742+ [INFO] Finished at: 2024-01-15T10:30:00Z
1743+ [INFO] ------------------------------------------------------------------------"# ;
1744+
1745+ let result = filter_mvn_compile ( input) ;
1746+ assert_eq ! (
1747+ result,
1748+ "✓ mvn compile: 42 sources compiled (Total time: 3.456 s)"
1749+ ) ;
1750+ }
1751+
1752+ #[ test]
1753+ fn test_filter_test_all_pass_exact_output ( ) {
1754+ let input = r#"[INFO] Tests run: 15, Failures: 0, Errors: 0, Skipped: 2
1755+ [INFO] BUILD SUCCESS
1756+ [INFO] Total time: 5.678 s"# ;
1757+
1758+ let result = filter_mvn_test ( input) ;
1759+ assert_eq ! (
1760+ result,
1761+ "✓ mvn test: 15 passed, 2 skipped (Total time: 5.678 s)"
1762+ ) ;
1763+ }
1764+
1765+ #[ test]
1766+ fn test_filter_clean_success_exact_output ( ) {
1767+ let input = r#"[INFO] --- maven-clean-plugin:3.3.1:clean (default-clean) @ myapp ---
1768+ [INFO] Deleting /home/user/myapp/target
1769+ [INFO] BUILD SUCCESS
1770+ [INFO] Total time: 0.456 s"# ;
1771+
1772+ let result = filter_mvn_clean ( input) ;
1773+ assert_eq ! ( result, "✓ mvn clean: Done (Total time: 0.456 s)" ) ;
1774+ }
1775+
1776+ #[ test]
1777+ fn test_filter_package_success_exact_output ( ) {
1778+ let input = r#"[INFO] Tests run: 15, Failures: 0, Errors: 0, Skipped: 0
1779+ [INFO] Building jar: /home/user/myapp/target/myapp-1.0-SNAPSHOT.jar
1780+ [INFO] BUILD SUCCESS
1781+ [INFO] Total time: 12.345 s"# ;
1782+
1783+ let result = filter_mvn_package ( input) ;
1784+ assert_eq ! (
1785+ result,
1786+ "✓ mvn package: myapp-1.0-SNAPSHOT.jar (15 tests passed) [Total time: 12.345 s]"
1787+ ) ;
1788+ }
1789+
1790+ #[ test]
1791+ fn test_filter_install_success_exact_output ( ) {
1792+ let input = r#"[INFO] Tests run: 15, Failures: 0, Errors: 0, Skipped: 0
1793+ [INFO] Installing /home/user/myapp/target/myapp-1.0-SNAPSHOT.jar to /home/user/.m2/repository/com/example/myapp/1.0-SNAPSHOT/myapp-1.0-SNAPSHOT.jar
1794+ [INFO] BUILD SUCCESS
1795+ [INFO] Total time: 15.678 s"# ;
1796+
1797+ let result = filter_mvn_install ( input) ;
1798+ assert_eq ! (
1799+ result,
1800+ "✓ mvn install: myapp-1.0-SNAPSHOT.jar installed (15 tests passed) [Total time: 15.678 s]"
1801+ ) ;
1802+ }
1803+
15321804 #[ test]
15331805 fn test_filter_compile_with_warnings ( ) {
15341806 let input = r#"[INFO] Scanning for projects...
0 commit comments