summaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
authorRohan McGovern <rohan.mcgovern@nokia.com>2012-07-03 13:39:11 +1000
committerRohan McGovern <rohan.mcgovern@nokia.com>2012-07-09 03:57:37 +0200
commit3fb57a96f55998a7c9465bb516702bffa7085e4a (patch)
tree53ee24eb1db6a5f51351e70f088a1e3e593a821b /t
parent045670d20b07c168f1b9b19581b666fcfdf5587f (diff)
test.pl: don't assume a single Jenkins axis
Don't assume that the job name is always $base/cfg=$cfg ; other axes may be defined. Add a test for this. Change-Id: Ifbf687ba2a7cb1b18b1bb053b405a4d2656e2ec1 Reviewed-by: Sergio Ahumada <sergio.ahumada@nokia.com> Reviewed-by: Kalle Lehtonen <kalle.ju.lehtonen@nokia.com>
Diffstat (limited to 't')
-rw-r--r--t/01-test.t68
1 files changed, 67 insertions, 1 deletions
diff --git a/t/01-test.t b/t/01-test.t
index 38628bc2..ff060da9 100644
--- a/t/01-test.t
+++ b/t/01-test.t
@@ -2,7 +2,7 @@
use strict;
use warnings;
-use Test::More tests => 103;
+use Test::More tests => 127;
use FindBin;
use File::Basename;
use IO::Capture::Stdout;
@@ -178,6 +178,71 @@ sub test_projects
}
}
+sub test_environment
+{
+ clean_environment;
+
+ my ($project_env, $stage_env, $ci_environment, $possible_ci_environments);
+
+ # Clean environment: nothing set
+ ($project_env, $stage_env, $ci_environment, $possible_ci_environments) = QtQATest::_get_project_config_from_ci_tool( );
+ ok( !$project_env, 'no project_env set with clean environment' );
+ ok( !$stage_env, 'no stage_env set with clean environment' );
+ ok( !$ci_environment, 'no ci_environment set with clean environment' );
+ is( $possible_ci_environments, 'Pulse or Jenkins', 'possible envs as expected with clean environment' );
+
+ # Basic Pulse setup
+ {
+ local $ENV{ PULSE_PROJECT } = 'a project';
+ local $ENV{ PULSE_STAGE } = 'a stage';
+ ($project_env, $stage_env, $ci_environment, $possible_ci_environments) = QtQATest::_get_project_config_from_ci_tool( );
+ is( $project_env, 'a project', 'project_env set with pulse environment' );
+ is( $stage_env, 'a stage', 'stage_env set with pulse environment' );
+ is( $ci_environment, 'Pulse', 'pulse ci_environment set with pulse environment' );
+ is( $possible_ci_environments, 'Pulse or Jenkins', 'possible envs as expected with pulse environment' );
+ }
+
+ # Basic Jenkins setup
+ {
+ local $ENV{ JOB_NAME } = 'a_job/cfg=a_cfg';
+ ($project_env, $stage_env, $ci_environment, $possible_ci_environments) = QtQATest::_get_project_config_from_ci_tool( );
+ is( $project_env, 'a_job', 'project_env set with jenkins environment' );
+ is( $stage_env, 'a_cfg', 'stage_env set with jenkins environment' );
+ is( $ci_environment, 'Jenkins', 'jenkins ci_environment set with jenkins environment' );
+ is( $possible_ci_environments, 'Pulse or Jenkins', 'possible envs as expected with jenkins environment' );
+ }
+
+ # Jenkins setup, other key before
+ {
+ local $ENV{ JOB_NAME } = 'other_job/key1=val1,cfg=other_cfg';
+ ($project_env, $stage_env, $ci_environment, $possible_ci_environments) = QtQATest::_get_project_config_from_ci_tool( );
+ is( $project_env, 'other_job', 'project_env set with jenkins environment' );
+ is( $stage_env, 'other_cfg', 'stage_env set with jenkins environment' );
+ is( $ci_environment, 'Jenkins', 'jenkins ci_environment set with jenkins environment' );
+ is( $possible_ci_environments, 'Pulse or Jenkins', 'possible envs as expected with jenkins environment' );
+ }
+
+ # Jenkins setup, other key after
+ {
+ local $ENV{ JOB_NAME } = 'another_job/cfg=another_cfg,key1=val1';
+ ($project_env, $stage_env, $ci_environment, $possible_ci_environments) = QtQATest::_get_project_config_from_ci_tool( );
+ is( $project_env, 'another_job', 'project_env set with jenkins environment' );
+ is( $stage_env, 'another_cfg', 'stage_env set with jenkins environment' );
+ is( $ci_environment, 'Jenkins', 'jenkins ci_environment set with jenkins environment' );
+ is( $possible_ci_environments, 'Pulse or Jenkins', 'possible envs as expected with jenkins environment' );
+ }
+
+ # Jenkins setup, other key before and after
+ {
+ local $ENV{ JOB_NAME } = 'great_job/key1=val1,cfg=great_cfg,key2=val2';
+ ($project_env, $stage_env, $ci_environment, $possible_ci_environments) = QtQATest::_get_project_config_from_ci_tool( );
+ is( $project_env, 'great_job', 'project_env set with jenkins environment' );
+ is( $stage_env, 'great_cfg', 'stage_env set with jenkins environment' );
+ is( $ci_environment, 'Jenkins', 'jenkins ci_environment set with jenkins environment' );
+ is( $possible_ci_environments, 'Pulse or Jenkins', 'possible envs as expected with jenkins environment' );
+ }
+}
+
my $testdatadir = "$FindBin::Bin/testdata";
debug "$testdatadir:\n";
@@ -188,3 +253,4 @@ foreach my $testdata (glob "$testdatadir/*") {
test_projects(testdata => $testdata);
}
+test_environment();