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

Standardize a bit std/validity tests #324

Merged
merged 5 commits into from
Jul 22, 2024

Conversation

Mte90
Copy link
Member

@Mte90 Mte90 commented Jul 18, 2024

Ref #319

@Mte90 Mte90 marked this pull request as ready for review July 18, 2024 08:55
@Mte90
Copy link
Member Author

Mte90 commented Jul 18, 2024

If you guys have other ideas to standardize a bit the tests I am here

@CymDeveloppement
Copy link
Member

I work on a run_in_tmp function related to #447 and for my professional usage.

pub fun run_in_tmp(): Null {
    if(not shell_isset("CURRENT_TMP_DIR")) {
        $cd \$(mktemp -d /tmp/XXXXXX)$ failed {
            error("Failed to create temp folder")
            exit(1)
        }
        let tmp_dir = unsafe $pwd$
        unsafe shell_constant_set("CURRENT_TMP_DIR", tmp_dir)
        unsafe $trap "rm -Rf \$CURRENT_TMP_DIR" EXIT$    
    } else {
        unsafe $cd \$CURRENT_TMP_DIR$
    }
}

maybe i can make a pull request quickly ?

@CymDeveloppement
Copy link
Member

I work on a run_in_tmp function related to #447 and for my professional usage.

pub fun run_in_tmp(): Null {
    if(not shell_isset("CURRENT_TMP_DIR")) {
        $cd \$(mktemp -d /tmp/XXXXXX)$ failed {
            error("Failed to create temp folder")
            exit(1)
        }
        let tmp_dir = unsafe $pwd$
        unsafe shell_constant_set("CURRENT_TMP_DIR", tmp_dir)
        unsafe $trap "rm -Rf \$CURRENT_TMP_DIR" EXIT$    
    } else {
        unsafe $cd \$CURRENT_TMP_DIR$
    }
}

maybe i can make a pull request quickly ?

this simplify test code, just call run_in_tmp(), no absolute path in code and all file is deleted on exit.

@Mte90
Copy link
Member Author

Mte90 commented Jul 18, 2024

So I checked we have just one test that have "Hello, Amber!" so it isn't worth it a placeholder as we manipulate strings a lot.
About your proposal we need to see how we can execute that for all the tests automatically.

@CymDeveloppement
Copy link
Member

So I checked we have just one test that have "Hello, Amber!" so it isn't worth it a placeholder as we manipulate strings a lot. About your proposal we need to see how we can execute that for all the tests automatically.

maybe many test can be rewrite with Hello, Amber! output

import * from "std"
main {
    let tmpdir = unsafe $mktemp -d /tmp/amber-XXXX$
    unsafe $cd {tmpdir}$
    unsafe $touch test.txt$
    if file_exist("./test.txt") {
        echo "Hello, Amber!"
    } else {
        echo "Not Found"
    }
    unsafe $rm -fr {tmpdir}$
}

@CymDeveloppement
Copy link
Member

So I checked we have just one test that have "Hello, Amber!" so it isn't worth it a placeholder as we manipulate strings a lot. About your proposal we need to see how we can execute that for all the tests automatically.

maybe many test can be rewrite with Hello, Amber! output

import * from "std"
main {
    let tmpdir = unsafe $mktemp -d /tmp/amber-XXXX$
    unsafe $cd {tmpdir}$
    unsafe $touch test.txt$
    if file_exist("./test.txt") {
        echo "Hello, Amber!"
    } else {
        echo "Not Found"
    }
    unsafe $rm -fr {tmpdir}$
}

this also a Standardization of test

@Mte90
Copy link
Member Author

Mte90 commented Jul 18, 2024

Maybe it is better something like "Succeed", we have tests with created, found and so on

@CymDeveloppement
Copy link
Member

So I checked we have just one test that have "Hello, Amber!" so it isn't worth it a placeholder as we manipulate strings a lot. About your proposal we need to see how we can execute that for all the tests automatically.

running in tmp directory can be explicit, not all test require files/directories creation.

@Mte90 Mte90 changed the title Standardize a bit std tests Standardize a bit std/validity tests Jul 18, 2024
@Mte90
Copy link
Member Author

Mte90 commented Jul 18, 2024

Implemented for stdlib/validity tests the default value.

About your code I think that is better to run all the tests in a temporary folder so they are sandboxed, and inside it is created another folder.
We just need to see how to implement that but it is stuff for another ticket.

@Mte90 Mte90 merged commit 494da76 into amber-lang:master Jul 22, 2024
1 check passed
@Mte90 Mte90 deleted the test-remove-folder branch July 22, 2024 09:35
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

Successfully merging this pull request may close these issues.

3 participants