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

Add ripgrep in documentation to test with just ci #2491

Closed
vtamara opened this issue Dec 1, 2024 · 4 comments
Closed

Add ripgrep in documentation to test with just ci #2491

vtamara opened this issue Dec 1, 2024 · 4 comments

Comments

@vtamara
Copy link
Contributor

vtamara commented Dec 1, 2024

After compiling just on OpenBSD/adJ 7.6beta1 and trying to test with just ci I obtained:

 % just ci                                                                                                                                           
./bin/forbid                                                                                                                                                    
+ which rg                                                                      
which: rg: Command not found.                                                   
error: Recipe `forbid` failed on line 123 with exit code 2

I discovered that rg is ripgrep. On OpenBSD/adJ I installed with doas pkg_add ripgrep and after that I could run the tests.

By the way only 3 tests failed:

...
failures:                                                                                                                                                       
                                                                                                                                                                
---- attributes::multiple_attributes_one_line stdout ----                                                                                                       
Bad stderr: Diff < left / right > :                                                                                                                             
<error: Justfile contains no recipes.                                                                                                                           
>exit 1                                                                                                                                                         
                                                                                                                                                                    
thread 'attributes::multiple_attributes_one_line' panicked at tests/attributes.rs:59:6:                                                                         
Output mismatch.                                                                                                                                                
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace                                                                                   
                                                                                                                                                                
---- constants::constants_are_not_exported stdout ----                                                                                                          
thread 'constants::constants_are_not_exported' panicked at tests/constants.rs:60:6:                                                                             
Stderr regex mismatch:                                                                                                                                          
"echo $HEXUPPER\nbash: línea 1: HEXUPPER: variable sin asignar\nerror: Recipe `foo` failed on line 4 with exit code 127\n"                                      
!~=                                                                                                                                                             
/Regex("^(?s).*HEXUPPER: unbound variable.*$")/                                                                                                                 
                                                                                                                                                                
---- os_attributes::os stdout ----                                                                                                                              
thread 'os_attributes::os' panicked at tests/os_attributes.rs:59:7:
  unexpected os family                                                                                                                                            
                                                                                                                                                                
                                                                                                                                                                
failures:                                                                                                                                                       
    attributes::multiple_attributes_one_line                                                                                                                    
    constants::constants_are_not_exported                                                                                                                       
    os_attributes::os                                                                                                                                           
                                                                                                                                                                
test result: FAILED. 849 passed; 3 failed; 7 ignored; 0 measured; 0 filtered out; finished in 17.29s                                                            
                                                                                                                                                                
error: test failed, to rerun pass `-p just --test integration`                                                                                                  
error: Recipe `test` failed on line 17 with exit code 101 
vtamara added a commit to vtamara/just that referenced this issue Dec 1, 2024
@olfa-arfani
Copy link

for the constants_are_not_exported function
would it be possible to replace

fn constants_are_not_exported() {
 Test::new()
   .justfile(
     "
       set export

       foo:
         echo $HEXUPPER
     ",
   )
   .stderr_regex(".*HEXUPPER: unbound variable.*")
   .status(127)
   .run();
}

by

fn constants_are_not_exported() {
 Test::new()
   .justfile(
     "
       foo:
          echo "source $HOME/$HEXUPPER" >> ~/.bashrc
     ",
   )
   .stderr_regex(".*HEXUPPER: unbound variable.*")
   .status(127)
   .run();
}

inspired from #1808

@laniakea64
Copy link
Contributor

laniakea64 commented Dec 1, 2024

Please don't make the just test suite modify (or risk modifying) customized user configuration files, especially ones that are tricky to get correct and interact with other configurations.

The issue OP is seeing with that test case is that the text "unbound variable" is translated for them, but the test case assumes that part of the error message will always be in English. Maybe that test should set environment variables to make the shell use C locale for error messages?

@vtamara
Copy link
Contributor Author

vtamara commented Dec 1, 2024

Thanks @olfa-arfani and @laniakea64

Running RUST_BACKTRACE=1 cargo test I obtain:

---- attributes::multiple_attributes_one_line stdout ----                       
Bad stderr: Diff < left / right > :     
<error: Justfile contains no recipes.   
>exit 1                                 
                                        

thread 'attributes::multiple_attributes_one_line' panicked at tests/attributes.rs:59:6:
Output mismatch.                        
stack backtrace:                        
   0: rust_begin_unwind                 
   1: core::panicking::panic_fmt        
   2: integration::test::Test::run      
             at ./tests/test.rs:293:7   
   3: integration::attributes::multiple_attributes_one_line                     
             at ./tests/attributes.rs:48:3                                      
   4: integration::attributes::multiple_attributes_one_line::{{closure}}        
             at ./tests/attributes.rs:47:34                                     
   5: core::ops::function::FnOnce::call_once                                    
             at /usr/obj/ports/rust-1.81.0/rustc-1.81.0-src/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

---- constants::constants_are_not_exported stdout ----          
thread 'constants::constants_are_not_exported' panicked at tests/constants.rs:60:6:
Stderr regex mismatch:                  
"echo $HEXUPPER\nbash: línea 1: HEXUPPER: variable sin asignar\nerror: Recipe `foo` failed on line 4 with exit code 127\n"
!~=                                     
/Regex("^(?s).*HEXUPPER: unbound variable.*$")/                                 
stack backtrace:                                                                                                                                                
   0: rust_begin_unwind                 
   1: core::panicking::panic_fmt        
   2: integration::test::Test::run      
             at ./tests/test.rs:283:7   
   3: integration::constants::constants_are_not_exported                        
             at ./tests/constants.rs:49:3                                       
   4: integration::constants::constants_are_not_exported::{{closure}}           
             at ./tests/constants.rs:48:32                                      
   5: core::ops::function::FnOnce::call_once                                    
             at /usr/obj/ports/rust-1.81.0/rustc-1.81.0-src/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
                                                                                                                                                                
---- os_attributes::os stdout ----                                                                                                                              
thread 'os_attributes::os' panicked at tests/os_attributes.rs:59:7:             
unexpected os family 
stack backtrace:                                                                                                                                                
   0: rust_begin_unwind                 
   1: core::panicking::panic_fmt                                                                                                                                
   2: integration::os_attributes::os    
             at ./tests/os_attributes.rs:59:7                                   
   3: integration::os_attributes::os::{{closure}}                                                                                                               
             at ./tests/os_attributes.rs:35:8                                   
   4: core::ops::function::FnOnce::call_once                                    
             at /usr/obj/ports/rust-1.81.0/rustc-1.81.0-src/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
                                                                                
                                                                                
failures:                                                                       
    attributes::multiple_attributes_one_line                                    
    constants::constants_are_not_exported                                       
    os_attributes::os                                                                                                                                           
                                                                                                                                                                
test result: FAILED. 849 passed; 3 failed; 7 ignored; 0 measured; 0 filtered out; finished in 21.45s                                                            
                                                                                                                                                                
error: test failed, to rerun pass `--test integration`                          

@casey
Copy link
Owner

casey commented Dec 1, 2024

Thanks for opening this! I just merged #2493, which prints out a better error message in case ripgrep is missing. I think the test failures should be separate issues.

@casey casey closed this as completed Dec 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants