pointfreeco / swift-snapshot-testing

📸 Delightful Swift snapshot testing.
https://www.pointfree.co/episodes/ep41-a-tour-of-snapshot-testing
MIT License
3.74k stars 570 forks source link

[Feat] globla var artifactsUrl #724

Closed Wei18 closed 9 months ago

Wei18 commented 1 year ago

Summary:

Would like to upload artifacts when CI running but test results failed, but ProcessInfo.processInfo.environment["SNAPSHOT_ARTIFACTS"] is hardly to control.

Detail:

Like snapshotDirectory, but artifactDirectory.

Wei18 commented 9 months ago
import Foundation

// Get the current environment variables
var environment = ProcessInfo.processInfo.environment
print("Current Environment: \(environment)")

// Set a new environment variable
let newEnvironmentValue = "NewValue"
setenv("NEW_VARIABLE", newEnvironmentValue, 1)  // The third parameter is used to specify whether to replace an existing variable with the same name

// Retrieve the environment variables again to check if the setting was successful
environment = ProcessInfo.processInfo.environment
print("Updated Environment: \(environment)")