Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show content of generated test, build script and output and error in 'buildtest build' #1779

Merged
merged 2 commits into from
May 20, 2024

Conversation

shahzebsiddiqui
Copy link
Member

The output of buildtest build will now show the content of the output, error and test and buildscript. Shown below is a sample output

(buildtest) ☁  buildtest [show_test_content_in_buildtest_build_output] ⚡  buildtest build -b tutorials/vars.yml                      
╭──────────────────────────────────────── buildtest summary ────────────────────────────────────────╮                                                                                                                              
│                                                                                                   │                                                                                                                              
│ User:               siddiq90                                                                      │                                                                                                                              
│ Hostname:           DOE7648057                                                                    │                                                                                                                              
│ Platform:           Darwin                                                                        │                                                                                                                              
│ Current Time:       2024/05/17 16:02:38                                                           │                                                                                                                              
│ buildtest path:     /Users/siddiq90/Documents/buildtest/bin/buildtest                             │                                                                                                                              
│ buildtest version:  2.0                                                                           │                                                                                                                              
│ python path:        /Users/siddiq90/.local/share/virtualenvs/buildtest-1gHVG2Pd/bin/python3       │                                                                                                                              
│ python version:     3.11.7                                                                        │                                                                                                                              
│ Configuration File: /Users/siddiq90/Documents/buildtest/buildtest/settings/config.yml             │                                                                                                                              
│ Test Directory:     /Users/siddiq90/Documents/buildtest/var/tests                                 │                                                                                                                              
│ Report File:        /Users/siddiq90/Documents/buildtest/var/report.json                           │                                                                                                                              
│ Command:            /Users/siddiq90/Documents/buildtest/bin/buildtest build -b tutorials/vars.yml │                                                                                                                              
│                                                                                                   │                                                                                                                              
╰───────────────────────────────────────────────────────────────────────────────────────────────────╯                                                                                                                              
─────────────────────────────────────────────────────────────────────────────────────────────────────  Discovering Buildspecs ─────────────────────────────────────────────────────────────────────────────────────────────────────
                  Discovered buildspecs                   
╔════════════════════════════════════════════════════════╗
║ buildspec                                              ║
╟────────────────────────────────────────────────────────╢
║ /Users/siddiq90/Documents/buildtest/tutorials/vars.yml ║
╟────────────────────────────────────────────────────────╢
║ Total: 1                                               ║
╚════════════════════════════════════════════════════════╝


Total Discovered Buildspecs:  1
Total Excluded Buildspecs:  0
Detected Buildspecs after exclusion:  1
─────────────────────────────────────────────────────────────────────────────────────────────────────── Parsing Buildspecs ────────────────────────────────────────────────────────────────────────────────────────────────────────
Valid Buildspecs: 1
Invalid Buildspecs: 0
/Users/siddiq90/Documents/buildtest/tutorials/vars.yml: VALID
Total builder objects created: 1
                                                                            Builders by type=script                                                                            
┏━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━┳━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ builder                 ┃ type   ┃ executor           ┃ compiler ┃ nodes ┃ procs ┃ description                     ┃ buildspecs                                             ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━╇━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ variables_bash/a894eddf │ script │ generic.local.bash │ None     │ None  │ None  │ Declare shell variables in bash │ /Users/siddiq90/Documents/buildtest/tutorials/vars.yml │
└─────────────────────────┴────────┴────────────────────┴──────────┴───────┴───────┴─────────────────────────────────┴────────────────────────────────────────────────────────┘
────────────────────────────────────────────────────────────────────────────────────────────────────────── Building Test ──────────────────────────────────────────────────────────────────────────────────────────────────────────
variables_bash/a894eddf: Creating Test Directory: /Users/siddiq90/Documents/buildtest/var/tests/generic.local.bash/vars/variables_bash/a894eddf
────────────────────────────────────────────────────────────────────────────────────────── variables_bash/a894eddf: Start of Test Script ──────────────────────────────────────────────────────────────────────────────────────────
#!/bin/bash                                                                                                                                                                                                                        
X="1"                                                                                                                                                                                                                              
Y="2"                                                                                                                                                                                                                              
literalstring="this is a literal string"                                                                                                                                                                                           
singlequote="\'singlequote\'"                                                                                                                                                                                                      
doublequote="\"doublequote\""                                                                                                                                                                                                      
current_user="$(whoami)"                                                                                                                                                                                                           
num_files="`find $HOME -type f -maxdepth 1 | wc -l`"                                                                                                                                                                               
multiline_string="Hello my name is Bob \n                                                                                                                                                                                          
I am 30 years old                                                                                                                                                                                                                  
"                                                                                                                                                                                                                                  
# Content of run section                                                                                                                                                                                                           
echo "$X+$Y="$(($X+$Y))                                                                                                                                                                                                            
echo $literalstring                                                                                                                                                                                                                
echo $singlequote                                                                                                                                                                                                                  
echo $doublequote                                                                                                                                                                                                                  
echo "current user:" $current_user                                                                                                                                                                                                 
echo "number of files:" $num_files                                                                                                                                                                                                 
echo -e $multiline_string                                                                                                                                                                                                          
                                                                                                                                                                                                                                   
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
───────────────────────────────────────────────────────────────────────────────────────── variables_bash/a894eddf: Start of Build Script ──────────────────────────────────────────────────────────────────────────────────────────
#!/bin/bash                                                                                                                                                                                                                        
                                                                                                                                                                                                                                   
# Function to handle all signals and perform cleanup                                                                                                                                                                               
function cleanup() {                                                                                                                                                                                                               
    echo "Signal trapped. Performing cleanup before exiting."                                                                                                                                                                      
    exitcode=$?                                                                                                                                                                                                                    
    echo "buildtest: command \`$BASH_COMMAND' failed (exit code: $exitcode)"                                                                                                                                                       
    exit $exitcode                                                                                                                                                                                                                 
}                                                                                                                                                                                                                                  
                                                                                                                                                                                                                                   
# Trap all signals and call the cleanup function                                                                                                                                                                                   
trap cleanup SIGINT SIGTERM SIGHUP SIGQUIT SIGABRT SIGKILL SIGALRM SIGPIPE SIGTERM SIGTSTP SIGTTIN SIGTTOU                                                                                                                         
                                                                                                                                                                                                                                   
export BUILDTEST_TEST_NAME=variables_bash                                                                                                                                                                                          
export BUILDTEST_TEST_ROOT=/Users/siddiq90/Documents/buildtest/var/tests/generic.local.bash/vars/variables_bash/a894eddf                                                                                                           
export BUILDTEST_BUILDSPEC_DIR=/Users/siddiq90/Documents/buildtest/tutorials                                                                                                                                                       
export BUILDTEST_STAGE_DIR=/Users/siddiq90/Documents/buildtest/var/tests/generic.local.bash/vars/variables_bash/a894eddf/stage                                                                                                     
# source executor startup script                                                                                                                                                                                                   
source /Users/siddiq90/Documents/buildtest/var/executor/generic.local.bash/before_script.sh                                                                                                                                        
# Run generated script                                                                                                                                                                                                             
bash  /Users/siddiq90/Documents/buildtest/var/tests/generic.local.bash/vars/variables_bash/a894eddf/stage/variables_bash.sh                                                                                                        
# Get return code                                                                                                                                                                                                                  
returncode=$?                                                                                                                                                                                                                      
# Exit with return code                                                                                                                                                                                                            
exit $returncode                                                                                                                                                                                                                   
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
────────────────────────────────────────────────────────────────────────────────────────────────────────── Running Tests ──────────────────────────────────────────────────────────────────────────────────────────────────────────
Spawning 1 processes for processing builders
─────────────────────────────────────────────────────────────────────────────────────────────────────────── Iteration 1 ───────────────────────────────────────────────────────────────────────────────────────────────────────────
variables_bash/a894eddf does not have any dependencies adding test to queue
 Builders Eligible to Run  
┏━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Builder                 ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ variables_bash/a894eddf │
└─────────────────────────┘
variables_bash/a894eddf: Current Working Directory : /Users/siddiq90/Documents/buildtest/var/tests/generic.local.bash/vars/variables_bash/a894eddf/stage
variables_bash/a894eddf: Running Test via command: bash variables_bash_build.sh
──────────────────────────────────────────────────────────────────────────────────────────── variables_bash/a894eddf: Start of Output ─────────────────────────────────────────────────────────────────────────────────────────────
1+2=3                                                                                                                                                                                                                              
this is a literal string                                                                                                                                                                                                           
\'singlequote\'                                                                                                                                                                                                                    
"doublequote"                                                                                                                                                                                                                      
current user: siddiq90                                                                                                                                                                                                             
number of files: 18                                                                                                                                                                                                                
Hello my name is Bob                                                                                                                                                                                                               
 I am 30 years old                                                                                                                                                                                                                 
                                                                                                                                                                                                                                   
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
variables_bash/a894eddf: Test completed in 0.027626 seconds with returncode: 0
variables_bash/a894eddf: Writing output file -  /Users/siddiq90/Documents/buildtest/var/tests/generic.local.bash/vars/variables_bash/a894eddf/variables_bash.out
variables_bash/a894eddf: Writing error file - /Users/siddiq90/Documents/buildtest/var/tests/generic.local.bash/vars/variables_bash/a894eddf/variables_bash.err
                                  Test Summary                                  
┏━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━┓
┃ builder                 ┃ executor           ┃ status ┃ returncode ┃ runtime ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━┩
│ variables_bash/a894eddf │ generic.local.bash │ PASS   │ 0          │ 0.028   │
└─────────────────────────┴────────────────────┴────────┴────────────┴─────────┘



Passed Tests: 1/1 Percentage: 100.000%
Failed Tests: 0/1 Percentage: 0.000%


Adding 1 test results to report file: /Users/siddiq90/Documents/buildtest/var/report.json
Writing Logfile to /Users/siddiq90/Documents/buildtest/var/logs/buildtest_e68n55a0.log

Fix issue where post run script was showing up in output even if script was not executed.
Add console.rule statement to indicate start and end of each output section
…print content using rich syntax.

We invoke these methods for displaying output in buildtest build for test, build script, output and error.
We also call this method in buildtest inspect query output
@shahzebsiddiqui
Copy link
Member Author

here are some screenshots

Screenshot 2024-05-17 at 4 07 45 PM Screenshot 2024-05-17 at 4 07 58 PM Screenshot 2024-05-17 at 4 08 18 PM

Buildtest will also show output of post run script if there is one. Like when we run this following test

Screenshot 2024-05-17 at 4 05 26 PM

@shahzebsiddiqui shahzebsiddiqui merged commit 2eb29a5 into devel May 20, 2024
36 of 38 checks passed
@shahzebsiddiqui shahzebsiddiqui deleted the show_test_content_in_buildtest_build_output branch May 20, 2024 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant