11mod support;
22
3- use std :: fs ;
3+ use serde_json :: Value ;
44
5- use support:: { current_package_version, not_implemented_message, run_tnmsc, TestDir } ;
5+ use support:: {
6+ current_package_version, install_packaged_cli_container, not_implemented_message, tnmsc_command,
7+ } ;
68
79#[ test]
8- fn help_lists_supported_commands ( ) {
9- let result = run_tnmsc ( & [ "help" ] , & support:: workspace_root ( ) ) ;
10- result. assert_success ( "tnmsc help" ) ;
10+ fn packaged_cli_contract_runs_inside_testcontainer ( ) {
11+ if !support:: is_linux_x64_host ( ) {
12+ eprintln ! ( "skipping packaged contract smoke on unsupported host" ) ;
13+ return ;
14+ }
15+
16+ let container = install_packaged_cli_container ( ) ;
1117
18+ let help = container. exec ( & tnmsc_command ( & [ "help" ] ) ) ;
19+ help. assert_success ( "global tnmsc help" ) ;
1220 for expected in [ "install" , "dry-run" , "clean" , "plugins" , "version" , "help" ] {
1321 assert ! (
14- result . stdout. contains( expected) ,
22+ help . stdout. contains( expected) ,
1523 "help output should include `{expected}`.\n stdout:\n {}" ,
16- result . stdout
24+ help . stdout
1725 ) ;
1826 }
19- }
20-
21- #[ test]
22- fn version_matches_workspace_version ( ) {
23- let result = run_tnmsc ( & [ "version" ] , & support:: workspace_root ( ) ) ;
24- result. assert_success ( "tnmsc version" ) ;
25-
26- assert_eq ! ( result. stdout. trim( ) , current_package_version( ) ) ;
27- }
2827
29- #[ test]
30- fn plugins_lists_core_output_adaptors ( ) {
31- let result = run_tnmsc ( & [ "plugins" ] , & support:: workspace_root ( ) ) ;
32- result. assert_success ( "tnmsc plugins" ) ;
28+ let version = container. exec ( & tnmsc_command ( & [ "version" ] ) ) ;
29+ version. assert_success ( "global tnmsc version" ) ;
30+ assert_eq ! ( version. stdout. trim( ) , current_package_version( ) ) ;
3331
32+ let plugins = container. exec ( & tnmsc_command ( & [ "plugins" ] ) ) ;
33+ plugins. assert_success ( "global tnmsc plugins" ) ;
3434 for expected in [
3535 "CodexCLIOutputAdaptor" ,
3636 "ClaudeCodeCLIOutputAdaptor" ,
3737 "TraeOutputAdaptor" ,
3838 "OpencodeCLIOutputAdaptor" ,
3939 ] {
4040 assert ! (
41- result . stdout. contains( expected) ,
41+ plugins . stdout. contains( expected) ,
4242 "plugins output should include `{expected}`.\n stdout:\n {}" ,
43- result . stdout
43+ plugins . stdout
4444 ) ;
4545 }
46- }
47-
48- #[ test]
49- fn schema_output_writes_valid_json_in_integration_sandbox ( ) {
50- let temp_dir = TestDir :: new ( "tnmsc-schema-contract" ) ;
51- let schema_path = temp_dir. path ( ) . join ( "tnmsc.schema.json" ) ;
52- let schema_path_arg = schema_path. to_string_lossy ( ) . into_owned ( ) ;
5346
54- let result = run_tnmsc (
55- & [ "schema" , "--output" , & schema_path_arg] ,
56- & support:: workspace_root ( ) ,
57- ) ;
58- result. assert_success ( "tnmsc schema --output" ) ;
47+ let schema_output_path = "/tmp/tnmsc.schema.json" ;
48+ let schema = container. exec ( & tnmsc_command ( & [ "schema" , "--output" , schema_output_path] ) ) ;
49+ schema. assert_success ( "global tnmsc schema --output" ) ;
5950
60- let content = fs :: read_to_string ( & schema_path )
61- . unwrap_or_else ( |error| panic ! ( "failed to read {}: {error}" , schema_path . display ( ) ) ) ;
62- let parsed: serde_json :: Value = serde_json:: from_str ( & content )
51+ let schema_file = container . exec ( & format ! ( "cat {}" , support :: quote_shell ( schema_output_path ) ) ) ;
52+ schema_file . assert_success ( " read schema output" ) ;
53+ let parsed: Value = serde_json:: from_str ( & schema_file . stdout )
6354 . unwrap_or_else ( |error| panic ! ( "schema output should be valid JSON: {error}" ) ) ;
64-
6555 let object = parsed
6656 . as_object ( )
6757 . expect ( "schema output should be a top-level JSON object" ) ;
68-
6958 assert ! ( object. contains_key( "$schema" ) ) ;
7059 assert ! ( object. contains_key( "properties" ) ) ;
71- }
7260
73- #[ test]
74- fn install_like_commands_fail_with_not_implemented_contract ( ) {
7561 for ( args, command_name, display) in [
7662 ( & [ ] [ ..] , "install" , "tnmsc" ) ,
7763 ( & [ "install" ] [ ..] , "install" , "tnmsc install" ) ,
@@ -83,7 +69,7 @@ fn install_like_commands_fail_with_not_implemented_contract() {
8369 "tnmsc clean --dry-run" ,
8470 ) ,
8571 ] {
86- let result = run_tnmsc ( args , & support :: workspace_root ( ) ) ;
72+ let result = container . exec ( & tnmsc_command ( args ) ) ;
8773 result. assert_failure ( display) ;
8874
8975 let expected = not_implemented_message ( command_name) ;
0 commit comments