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

Test command line #1316

Merged
merged 17 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix
  • Loading branch information
raviqqe committed Jul 8, 2024
commit e6c98442fccb10d115f2ff535dda48a4126d15b1
30 changes: 30 additions & 0 deletions features/process-context/environment-variable.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
Feature: Environment variables
Scenario: Get an environment variables
Given a file named "main.scm" with:
"""scheme
(import (scheme base) (scheme process-context))

(write-string (cdr (get-environment-variable "FOO")))
"""
And I set the environment variable "FOO" to "bar"
When I successfully run `scheme main.scm hello`
Then the stdout should contain exactly "bar"

Scenario: Get environment variables
Given a file named "main.scm" with:
"""scheme
(import (scheme base) (scheme process-context))

(for-each
(lambda (pair)
(write-string (car pair))
(write-char #\=)
(write-string (cdr pair))
(newline))
(get-environment-variables))
"""
And I set the environment variable "FOO" to "bar"
And I set the environment variable "BAZ" to "qux"
When I successfully run `scheme main.scm hello`
Then the stdout should contain "FOO=bar"
And the stdout should contain "BAZ=qux"
9 changes: 8 additions & 1 deletion prelude.scm
Original file line number Diff line number Diff line change
Expand Up @@ -2257,7 +2257,14 @@
(define $$get-environment-variables (primitive 29))

(define command-line (delay (map code-points->string ($$command-line))))
(define get-environment-variables (delay ($$get-environment-variables)))
(define get-environment-variables
(delay
(map
(lambda (pair)
(cons
(code-points->string (car pair))
(code-points->string (cdr pair))))
($$get-environment-variables))))

(define (get-environment-variable name)
(assoc name (get-environment-variables)))
Expand Down
Loading