#!/bin/bash # -*- shell-script -*- global this_script := 'test-get-sourceline.sh' global abs_top_srcdir := '/src/external-vcs/sourceforge/bashdb' # Make sure $abs_top_srcdir has a trailing slash global abs_top_srcdir := "$(abs_top_srcdir%%/)/" # Test _Dbg_get_source_line proc test_get_source_line { _Dbg_get_source_line 2 $this_script assertEquals '# -*- shell-script -*-' $_Dbg_source_line } # Test check_line # test should appear after tests which read in source. proc test_get_source_line_with_spaces { global _Dbg_frame_last_filename := ""$(abs_top_srcdir)test/example/dir with spaces/bug.sh"" # Can't figure out how to get this packaged with autoconf, so this # will work with git only. _Dbg_frame_file if [[ -f $_Dbg_frame_filename ]] && [[ $_Dbg_frame_filename =~ 'frame.sh' ]] { _Dbg_get_source_line 2 assertEquals 'x=1' $_Dbg_source_line } else { startSkipping echo "Skipping test due to autoconf problems" assertEquals 'skipped' 'skipped' endSkipping } } if test '/src/external-vcs/sourceforge/bashdb' = '' { echo "Something is wrong abs_top_srcdir is not set." exit 1 } source ${abs_top_srcdir}test/unit/helper.sh source ${abs_top_srcdir}init/pre.sh source ${abs_top_srcdir}lib/filecache.sh source ${abs_top_srcdir}lib/file.sh source ${abs_top_srcdir}lib/frame.sh source ${abs_top_srcdir}lib/msg.sh global _Dbg_set_highlight := '''' set -- # reset $# so shunit2 doesn't get confused. [[ $0 == ${BASH_SOURCE} ]] && source ${shunit_file} (CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:this_script) op: Equal rhs: {(test-get-sourceline.sh)} spids: [6] ) ] spids: [6] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:abs_top_srcdir) op: Equal rhs: {(/src/external-vcs/sourceforge/bashdb)} spids: [10] ) ] spids: [10] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:abs_top_srcdir) op: Equal rhs: { (BracedVarSub token: suffix_op: (StringUnary op_id:VOp1_DPercent arg_word:{(Lit_Slash /)}) spids: [17 21] ) (/) } spids: [16] ) ] spids: [16] ) (FuncDef name: test_get_source_line body: (BraceGroup children: [ (C {(_Dbg_get_source_line)} {(2)} {($ VSub_Name "$this_script")}) (C {(assertEquals)} {(SQ <"# -*- shell-script -*-">)} {(DQ ($ VSub_Name "$_Dbg_source_line"))} ) ] spids: [32] ) spids: [28 31] ) (FuncDef name: test_get_source_line_with_spaces body: (BraceGroup children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:_Dbg_frame_last_filename) op: Equal rhs: {(DQ (${ VSub_Name abs_top_srcdir) ("test/example/dir with spaces/bug.sh"))} spids: [68] ) ] spids: [68] ) (C {(_Dbg_frame_file)}) (If arms: [ (if_arm cond: [ (Sentence child: (AndOr children: [ (DBracket expr: (BoolUnary op_id: BoolUnary_f child: {($ VSub_Name "$_Dbg_frame_filename")} ) ) (DBracket expr: (BoolBinary op_id: BoolBinary_EqualTilde left: {($ VSub_Name "$_Dbg_frame_filename")} right: {(SQ )} ) ) ] op_id: Op_DAmp ) terminator: ) ] action: [ (C {(_Dbg_get_source_line)} {(2)}) (C {(assertEquals)} {(SQ <"x=1">)} {(DQ ($ VSub_Name "$_Dbg_source_line"))}) ] spids: [-1 114] ) ] else_action: [ (C {(startSkipping)}) (C {(echo)} {(DQ ("Skipping test due to autoconf problems"))}) (C {(assertEquals)} {(SQ )} {(SQ )}) (C {(endSkipping)}) ] spids: [133 160] ) ] spids: [65] ) spids: [61 64] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(SQ )} {(Lit_Other "=")} {(SQ )} {(Lit_Other "]")} ) terminator: ) ] action: [ (C {(echo)} {(DQ ("Something is wrong abs_top_srcdir is not set."))}) (C {(exit)} {(1)}) ] spids: [-1 182] ) ] spids: [-1 196] ) (C {(.)} {(${ VSub_Name abs_top_srcdir) (test/unit/helper.sh)}) (C {(.)} {(${ VSub_Name abs_top_srcdir) (init/pre.sh)}) (C {(.)} {(${ VSub_Name abs_top_srcdir) (lib/filecache.sh)}) (C {(.)} {(${ VSub_Name abs_top_srcdir) (lib/file.sh)}) (C {(.)} {(${ VSub_Name abs_top_srcdir) (lib/frame.sh)}) (C {(.)} {(${ VSub_Name abs_top_srcdir) (lib/msg.sh)}) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:_Dbg_set_highlight) op:Equal rhs:{(SQ )} spids:[241])] spids: [241] ) (C {(set)} {(--)}) (AndOr children: [ (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: {($ VSub_Number "$0")} right: {(${ VSub_Name BASH_SOURCE)} ) ) (C {(.)} {(${ VSub_Name shunit_file)}) ] op_id: Op_DAmp ) ] )