@@ -8,16 +8,13 @@ def read_fixture(name)
88end
99
1010def read_win_file_if_exists ( path )
11- # Use a script block with literals; avoid $variables to prevent transport/quoting expansion
12- # Also keep exit 0 regardless of existence so run_shell doesn't raise.
1311 ps = %{& { if (Test-Path -LiteralPath '#{ path } ') { Get-Content -Raw -LiteralPath '#{ path } ' } else { '<<<FILE_NOT_FOUND>>>' } } }
1412 r = run_shell ( %(powershell.exe -NoProfile -NonInteractive -Command "#{ ps } ") )
1513 body = ( r . stdout || '' ) . to_s
1614 exists = !body . include? ( '<<<FILE_NOT_FOUND>>>' )
1715 { exists : exists , content : exists ? body : '' }
1816end
1917
20- # ---- NEW: wrappers that always pass the required flags ----
2118def puppet_flags
2219 [
2320 '--preprocess_deferred' , 'true' ,
@@ -34,22 +31,16 @@ def apply_manifest_with_flags(manifest, opts = {})
3431def idempotent_apply_with_flags ( manifest , opts = { } )
3532 idempotent_apply ( manifest , opts . merge ( puppet_options : puppet_flags ) )
3633end
37- # ----------------------------------------------------------
38-
3934RSpec . configure do |config |
4035 config . before ( :all ) do
41- # Ensure Deferred values are preprocessed before provider runs (Puppet 8 default is false)
4236 run_shell ( 'puppet config set preprocess_deferred true --section agent' )
43- # Ensure JSON catalog serialization (avoids PSON issues with Deferred)
4437 run_shell ( 'puppet config set preferred_serialization_format json --section agent' )
4538
46- # Assert settings for clear diagnostics in CI logs
4739 pp = run_shell ( 'puppet config print preprocess_deferred --section agent' ) . stdout . strip
4840 fmt = run_shell ( 'puppet config print preferred_serialization_format --section agent' ) . stdout . strip
4941 raise 'preprocess_deferred not true on agent!' unless pp . casecmp ( 'true' ) . zero?
5042 raise 'preferred_serialization_format not json on agent!' unless fmt . casecmp ( 'json' ) . zero?
5143
52- # Extra visibility: show puppet version & confdir in logs
5344 run_shell ( 'puppet --version' )
5445 run_shell ( 'puppet config print confdir' )
5546 end
@@ -58,21 +49,16 @@ def idempotent_apply_with_flags(manifest, opts = {})
5849describe 'deferred values with dsc_lite' do
5950 let ( :control_manifest ) { read_fixture ( '01_file_deferred.pp' ) }
6051 let ( :dsc_deferred_direct ) { read_fixture ( '02_dsc_deferred_direct.pp' ) }
61- let ( :dsc_deferred_inline ) { read_fixture ( '02b_dsc_deferred_inline.pp' ) } # NEW
52+ let ( :dsc_deferred_inline ) { read_fixture ( '02b_dsc_deferred_inline.pp' ) }
6253 let ( :dsc_deferred_stringified ) { read_fixture ( '03a_dsc_deferred_stringified.pp' ) }
6354 let ( :dsc_deferred_bad_unwrap ) { read_fixture ( '03b_dsc_deferred_bad_unwrap.pp' ) }
6455
65- # ---- NEW: diagnostic example to prove effective settings for this process ----
66- it '00: confirms preprocess_deferred=true and JSON are active in the current apply context' do
67- print_pp = <<-PP
68- notify { "preprocess_deferred=#{ Puppet . lookup ( :settings ) . value ( 'preprocess_deferred' ) } ": }
69- notify { "preferred_serialization_format=#{ Puppet . lookup ( :settings ) . value ( 'preferred_serialization_format' ) } ": }
70- PP
71- res = apply_manifest_with_flags ( print_pp )
72- expect ( res . stdout ) . to match ( %r{preprocess_deferred=true}i )
73- expect ( res . stdout ) . to match ( %r{preferred_serialization_format=json}i )
56+ it '00: confirms preprocess_deferred=true and JSON are active in this context' do
57+ pp_out = run_shell ( 'puppet config print preprocess_deferred --section agent' ) . stdout . strip
58+ fmt_out = run_shell ( 'puppet config print preferred_serialization_format --section agent' ) . stdout . strip
59+ expect ( pp_out . downcase ) . to eq ( 'true' )
60+ expect ( fmt_out . downcase ) . to eq ( 'json' )
7461 end
75- # ------------------------------------------------------------------------------
7662
7763 it 'control (01): native file + Deferred resolves to hello-file' do
7864 result = idempotent_apply_with_flags ( control_manifest )
@@ -95,7 +81,6 @@ def idempotent_apply_with_flags(manifest, opts = {})
9581 end
9682 end
9783
98- # NEW 02b: inline Deferred on the DSC property (no variable intermediary)
9984 it '02b: passing Deferred inline to DSC resolves to hello-dsc-inline (otherwise flag bug)' do
10085 apply = apply_manifest_with_flags ( dsc_deferred_inline )
10186 out = read_win_file_if_exists ( 'C:/Temp/from_dsc_inline.txt' )
0 commit comments